i18n

Functions to internationalize your extension. You can use these APIs to get localized strings from locale files packaged with your extension, find out the browser's current language, and find out the value of its Accept-Language header.

See the Internationalization page for a guide on using this API.

Types

i18n.LanguageCode

A language tag such as "en-US" or "fr".

Functions

i18n.detectLanguage()

Detects the language of the provided text using the Compact Language Detector.

i18n.getMessage()

Gets the localized string for the specified message.

i18n.getAcceptLanguages()

Gets the accept-languages of the browser. This is different from the locale used by the browser. To get the locale, use i18n.getUILanguage.

i18n.getUILanguage()

Gets the UI language of the browser. This is different from i18n.getAcceptLanguages which returns the preferred user languages.

i18n.getPreferredSystemLanguages()

Returns the preferred locales of the operating system.

i18n.getSystemUILanguage()

Returns the current UI locale of the operating system.

Example extensions

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Firefox for Android
Safari on iOS
i18n
Chrome – Full support
Chrome 17 (Release date: 2012-02-08)
footnote Full support
Edge – Full support
Edge 14 (Release date: 2016-08-02)
footnote Full support
Firefox – Full support
Firefox 45 (Release date: 2016-03-08)
footnote Full support
Opera – Full support
Opera 15 (Release date: 2013-07-02)
footnote Full support
Safari – Full support
Safari 14 (Release date: 2020-09-16)
footnote Full support
Firefox for Android – Full support
Firefox for Android 48 (Release date: 2016-08-02)
footnote Full support
Safari on iOS – Full support
Safari on iOS 15 (Release date: 2021-09-20)
footnote Full support
LanguageCode
Chrome – Full support
Chrome 47 (Release date: 2015-12-01)
footnote Full support
Edge – Full support
Edge 14 (Release date: 2016-08-02)
footnote Full support
Firefox – Full support
Firefox 45 (Release date: 2016-03-08)
footnote Full support
Opera – Full support
Opera 34 (Release date: 2015-12-08)
footnote Full support
Safari – Full support
Safari 14 (Release date: 2020-09-16)
footnote Full support
Firefox for Android – Full support
Firefox for Android 48 (Release date: 2016-08-02)
footnote Full support
Safari on iOS – Full support
Safari on iOS 15 (Release date: 2021-09-20)
footnote Full support
detectLanguage
Chrome – Full support
Chrome 47 (Release date: 2015-12-01)
footnote Full support
Edge – Full support
Edge 79 (Release date: 2020-01-15)
footnote Full support
Firefox – Full support
Firefox 47 (Release date: 2016-06-07)
footnote Full support
Opera – Full support
Opera 34 (Release date: 2015-12-08)
footnote Full support
Safari – No support
Safari
footnote No support
Firefox for Android – No support
Firefox for Android 48 – 105 (Release date: 2016-08-02)
footnote The method existed but always threw an error.
Firefox for Android – Full support
Firefox for Android 106 (Release date: 2022-10-18)
footnote Full support
Safari on iOS – No support
Safari on iOS
footnote No support
getAcceptLanguages
Chrome – Full support
Chrome 47 (Release date: 2015-12-01)
footnote Full support
Edge – Full support
Edge 14 (Release date: 2016-08-02)
footnote Full support
Firefox – Full support
Firefox 47 (Release date: 2016-06-07)
footnote Full support
Opera – Full support
Opera 34 (Release date: 2015-12-08)
footnote Full support
Safari – Full support
Safari 14 (Release date: 2020-09-16)
footnote Full support
Firefox for Android – Full support
Firefox for Android 48 (Release date: 2016-08-02)
footnote Full support
Safari on iOS – Full support
Safari on iOS 15 (Release date: 2021-09-20)
footnote Full support
getMessage
Chrome – Full support
Chrome 17 (Release date: 2012-02-08)
footnote Full support
Edge – Full support
Edge 14 (Release date: 2016-08-02)
footnote
footnote Throws an exception instead returning an empty string if the message does not exist.
footnote Expects substitutions to be strings, while other browsers allow any value which is then converted to a string.
Firefox – Full support
Firefox 45 (Release date: 2016-03-08)
footnote
footnote Firefox 47 and earlier returns "??" instead of "" if the message is not found in _locales, bug 1258199 changed this act to match Chrome, landed on Firefox 48.
Opera – Full support
Opera 15 (Release date: 2013-07-02)
footnote Full support
Safari – Full support
Safari 14 (Release date: 2020-09-16)
footnote Full support
Firefox for Android – Full support
Firefox for Android 48 (Release date: 2016-08-02)
footnote Full support
Safari on iOS – Full support
Safari on iOS 15 (Release date: 2021-09-20)
footnote Full support
getPreferredSystemLanguages
Chrome – No support
Chrome
footnote No support
Edge – No support
Edge
footnote No support
Firefox – Full support
Firefox 141 (Release date: 2025-07-22)
footnote Full support
Opera – No support
Opera
footnote No support
Safari – Full support
Safari 18.4 (Release date: 2025-03-31)
footnote Full support
Firefox for Android – Full support
Firefox for Android 141 (Release date: 2025-07-22)
footnote Full support
Safari on iOS – Full support
Safari on iOS 18.4 (Release date: 2025-03-31)
footnote Full support
getSystemUILanguage
Chrome – No support
Chrome
footnote No support
Edge – No support
Edge
footnote No support
Firefox – No support
Firefox
footnote No support
Opera – No support
Opera
footnote No support
Safari – Full support
Safari 18.4 (Release date: 2025-03-31)
footnote Full support
Firefox for Android – No support
Firefox for Android
footnote No support
Safari on iOS – Full support
Safari on iOS 18.4 (Release date: 2025-03-31)
footnote Full support
getUILanguage
Chrome – Full support
Chrome 35 (Release date: 2014-05-20)
footnote Full support
Edge – Full support
Edge 14 (Release date: 2016-08-02)
footnote Full support
Firefox – Full support
Firefox 47 (Release date: 2016-06-07)
footnote
footnote Firefox 55 and earlier returns a language tag that's separated with the underscore character instead of hyphen, see bug 1374552.
Opera – Full support
Opera 22 (Release date: 2014-06-03)
footnote Full support
Safari – Full support
Safari 14 (Release date: 2020-09-16)
footnote Full support
Firefox for Android – Full support
Firefox for Android 48 (Release date: 2016-08-02)
footnote Full support
Safari on iOS – Full support
Safari on iOS 15 (Release date: 2021-09-20)
footnote Full support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
See implementation notes.
Has more compatibility info.

Note: This API is based on Chromium's chrome.i18n API. This documentation is derived from i18n.json in the Chromium code.

See also