i18n API
Hint
The i18n API is inherited from Firefox, and its primary documentation is maintained by Mozilla at MDN. Thunderbird implements only the subset of functions, events, and types listed here. The MDN pages may provide further details and examples, but they may also reference features that are not supported in Thunderbird.
Use the browser.i18n infrastructure to implement internationalization across your whole app or extension.
Manifest file properties
default_locale
l10n_resources
Functions
detectLanguage(text)
– [Added in TB 47]
Detects the language of the provided text using CLD.
getAcceptLanguages()
– [Added in TB 47]
Gets the accept-languages of the browser. This is different from the locale used by the browser; to get the locale, use getUILanguage().
getMessage(messageName, [substitutions])
– [Added in TB 45]
Gets the localized string for the specified message. If the message is missing, this method returns an empty string (‘’). If the format of the getMessage() call is wrong — for example, messageName is not a string or the substitutions array has more than 9 elements — this method returns undefined.
Note
Thunderbird 47 and earlier returns “??” instead of “” if the message is not found in _locales, bug 1258199 changed this act to match Chrome, landed on Thunderbird 48.
Parameters
messageName
The name of the message, as specified in the messages.json file.
substitutions
Substitution strings, if the message requires any.
getPreferredSystemLanguages()
Gets the preferred locales of the operating system. This is different from the locales set in the browser; to get those, use getAcceptLanguages().
getUILanguage()
– [Added in TB 47]
Gets the browser UI language of the browser. This is different from getAcceptLanguages() which returns the preferred user languages.
Note
Thunderbird 55 and earlier returns a language tag that’s separated with the underscore character instead of hyphen, see bug 1374552.
Types
LanguageCode
– [Added in TB 45]
An ISO language code such as en or fr. For a complete list of languages supported by this method, see kLanguageInfoTable. For an unknown language, und will be returned, which means that [percentage] of the text is unknown to CLD
string