electron-builder: NoSuchLanguageError: No known languages found for specification English.
- Version: 22.10.5
- Electron Version: 8.5.5
- Electron Type (current, beta, nightly):
- Target: macOS
If I try to build our application with electron-builder it fails with the following exception:
⨯ No known languages found for specification English. stackTrace=
NoSuchLanguageError: No known languages found for specification English.
at Function.bySpec (/Users/dmey/workspace/drive/node_modules/dmg-license/lib/Language.js:35:19)
at Object.indexByLanguage (/Users/dmey/workspace/drive/node_modules/dmg-license/lib/Language.js:81:41)
at labelCache (/Users/dmey/workspace/drive/node_modules/dmg-license/lib/assembleLicenses.js:92:35)
at Object.assembleLicenses [as default] (/Users/dmey/workspace/drive/node_modules/dmg-license/lib/assembleLicenses.js:117:23)
at dmgLicensePlist (/Users/dmey/workspace/drive/node_modules/dmg-license/lib/index.js:27:78)
at dmgLicense (/Users/dmey/workspace/drive/node_modules/dmg-license/lib/index.js:21:62)
at dmgLicenseFromJSON (/Users/dmey/workspace/drive/node_modules/dmg-license/lib/index.js:37:18)
at addLicenseToDmg (/Users/dmey/workspace/drive/node_modules/dmg-builder/src/dmgLicense.ts:57:9)
The exact same configuration is working on a workmates device.
We have a license_de.rtf, license_en.rtf, licenseButtons_de.json and a licenseButtons_en.json in our build directory.
Thanks for your help, best regards, Dominic
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 16
I borrowed a Mac and successfully reproduced your problem.
Problems
There are two things going on here:
licenseButtonspropertylangis supposed to be a language tag (likeen-us), but the documentation says to put a language name (likeEnglish) there. Doing this results in the error message you originally reported:No known languages found for specification English.I’ve opened issue #5887 about that.languageButtons_en-us.json).electron-builderexpects an underscore between the language and country (as inlanguageButtons_en_us.json), presumably for backward compatibility reasons. Putting a dash there results in the error message you reported just now:No known languages found for specification en-us-EN-US.Solutions
langproperty from alllicenseButtonsfiles. It’s not needed withelectron-builderand can only cause confusion.license_en_us.rtf,licenseButtons_en_us.json,license_de_de.rtf,licenseButtons_de_de.json.Giving a Language Name
You can give a language name in the
licenseButtonsfile (though it’s optional, except for languages marked “requireslanguageName” in the list). It goes in thelanguageNameproperty, notlang. Example:However, I don’t think current macOS actually displays the language name anywhere. It still expects a language name to appear in the DMG metadata, but there probably isn’t any benefit in providing a
languageNameunless it’s required.licenseButtonsAre OptionalFor several languages, including both US English and German, you don’t actually have to provide a
licenseButtonsfile at all. For any language marked as having “predefined labels” in the list, those predefined labels will be used if you don’t provide your own.Many thanks @argv-minus-one , your solution works fine 😃
@argv-minus-one It’s the same error with license_de-de.rtf, license_en-us.rtf, licenseButtons_de-de.json and licenseButtons_en-us.rtf
dmg-licenseonly recognizes a limited set of language tags, because those exact language tags correspond to the Classic Mac OS numeric language codes supported by Apple’sdmglicense format. Trying to use any other language tag, such asenorde, will result in the error above.So, try naming your license file something like
license_de-de.rtf(for German in RTF format) orlicense_en-us.txt(for US English in plain text format). Similarly, try using names likelicenseButtons_de-de.jsonfor the license buttons files.I notice that that the
electron-builderdocumentation links to this list of language tags. Again,dmg-licensewon’t recognize most of those. Theelectron-builderdocumentation should probably link to the list of language tags supported bydmg-licenseinstead.