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

Most upvoted comments

I borrowed a Mac and successfully reproduced your problem.

Problems

There are two things going on here:

  1. The licenseButtons property lang is supposed to be a language tag (like en-us), but the documentation says to put a language name (like English) 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.
  2. The code that parses the language tag out of your file name doesn’t work correctly if you put a dash in it (as in languageButtons_en-us.json). electron-builder expects an underscore between the language and country (as in languageButtons_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

  • Remove the lang property from all licenseButtons files. It’s not needed with electron-builder and can only cause confusion.
  • Rename all license files such that the language tag contains only underscores, not dashes: 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 licenseButtons file (though it’s optional, except for languages marked “requires languageName” in the list). It goes in the languageName property, not lang. Example:

{
  "languageName": "English, do you speak it",
  "agree": "Agree",
  "disagree": "Disagree",
  "print": "Print",
  "save": "Save",
  "description": "Here is my own description"
}

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 languageName unless it’s required.

licenseButtons Are Optional

For several languages, including both US English and German, you don’t actually have to provide a licenseButtons file 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

  ⨯ No known languages found for specification English.  failedTask=build stackTrace=NoSuchLanguageError: No known languages found for specification English.
    at Function.bySpec (/Users/dmey/.nvm/versions/node/v12.22.1/lib/node_modules/electron-builder/node_modules/dmg-license/lib/Language.js:35:19)
    at Object.indexByLanguage (/Users/dmey/.nvm/versions/node/v12.22.1/lib/node_modules/electron-builder/node_modules/dmg-license/lib/Language.js:81:41)
    at labelCache (/Users/dmey/.nvm/versions/node/v12.22.1/lib/node_modules/electron-builder/node_modules/dmg-license/lib/assembleLicenses.js:92:35)
    at Object.assembleLicenses [as default] (/Users/dmey/.nvm/versions/node/v12.22.1/lib/node_modules/electron-builder/node_modules/dmg-license/lib/assembleLicenses.js:117:23)
    at dmgLicensePlist (/Users/dmey/.nvm/versions/node/v12.22.1/lib/node_modules/electron-builder/node_modules/dmg-license/lib/index.js:27:78)
    at dmgLicense (/Users/dmey/.nvm/versions/node/v12.22.1/lib/node_modules/electron-builder/node_modules/dmg-license/lib/index.js:21:62)
    at Object.dmgLicenseFromJSON (/Users/dmey/.nvm/versions/node/v12.22.1/lib/node_modules/electron-builder/node_modules/dmg-license/lib/index.js:37:18)
    at Object.addLicenseToDmg (/Users/dmey/.nvm/versions/node/v12.22.1/lib/node_modules/electron-builder/node_modules/dmg-builder/src/dmgLicense.ts:59:9)
    at DmgTarget.build (/Users/dmey/.nvm/versions/node/v12.22.1/lib/node_modules/electron-builder/node_modules/dmg-builder/src/dmg.ts:73:25)

dmg-license only recognizes a limited set of language tags, because those exact language tags correspond to the Classic Mac OS numeric language codes supported by Apple’s dmg license format. Trying to use any other language tag, such as en or de, will result in the error above.

So, try naming your license file something like license_de-de.rtf (for German in RTF format) or license_en-us.txt (for US English in plain text format). Similarly, try using names like licenseButtons_de-de.json for the license buttons files.

I notice that that the electron-builder documentation links to this list of language tags. Again, dmg-license won’t recognize most of those. The electron-builder documentation should probably link to the list of language tags supported by dmg-license instead.