Наши волонтёры ещё не перевели данную статью на Русский. Присоединяйтесь к нам и помогите сделать эту работу!
Вы можете также прочитать эту статью на English (US).

Gets the localized string for the specified message.


  messageName,  // string
  substitutions // optional any


string. The name of the message, as specified in the messages.json file. If the message can't be found in messages.json:
  • Firefox returns "" and logs an error.
  • Chrome returns "" and does not log an error.
string or array of string. A single substitution string, or an array of substitution strings.
In Chrome, if you supply more than 9 substitution strings, getMessage() will return undefined.

Return value

string. Message localized for current locale.

Browser compatibility

Update compatibility data on GitHub
ChromeEdgeFirefoxOperaFirefox for Android
getMessageChrome Full support 17Edge Full support 14
Full support 14
Notes Throws an exception instead returning an empty string if the message does not exist.
Notes Expects substitutions to be strings, while other browsers allow any value which is then converted to a string.
Firefox Full support 45
Full support 45
Notes 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 15Firefox Android Full support 48


Full support  
Full support
See implementation notes.
See implementation notes.


Get the localized string for "messageContent", with target.url substituted:

var message = browser.i18n.getMessage("messageContent", target.url);

This would work with a _locales/en/messages.json file containing:

  "messageContent": {
    "message": "You clicked $URL$.",
    "description": "Tells the user which link they clicked.",
    "placeholders": {
      "url" : {
        "content" : "$1",
        "example" : "https://developer.mozilla.org"

If target.url is "https://developer.mozilla.org", then the value of message, in the "en" locale, would be:

"You clicked https://developer.mozilla.org."

Example extensions


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

Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.

Метки документа и участники

Внесли вклад в эту страницу: mdnwebdocs-bot, wbamberg, yfdyh000, Makyen
Обновлялась последний раз: mdnwebdocs-bot,