Extension Internationalization, messages.json and Locale Lookup
How to internationalize a browser extension with _locales, messages.json, browser.i18n, default_locale, and Chrome Web Store listing localization.
This page summarises Google Chrome extension documentation on internationalization (i18n): moving user-visible strings into messages.json, wiring them through manifest.json, CSS, and JavaScript, and aligning locales with the Chrome Web Store.
Use the
chrome.i18ninfrastructure to implement internationalization across your whole app or extension.— Google Chrome, browser.i18n
In Manifest V3, the same API is exposed as browser.i18n (with chrome.i18n still common in older samples). The file layout and lookup rules are the same; see the MV2 i18n reference for the parallel chrome.i18n wording.
_locales and messages.json: where translated strings live
Section titled “_locales and messages.json: where translated strings live”You put all user-visible strings in a file named messages.json. Each language gets its own directory under _locales, named with a locale code (for example en, es, ko).
You need to put all of its user-visible strings into a file named messages.json. Each time you add a new locale, you add a messages file under a directory named /_locales/localeCode, where localeCode is a code such as en for English.
— Google Chrome, browser.i18n
A minimal internationalized extension typically contains:
manifest.json, HTML, and JavaScript at the extension root_locales/en/messages.json,_locales/es/messages.json, and so on
To add Spanish, copy the default messages.json, translate the message values, and save it as _locales/es/messages.json. You do not need every key in every locale as long as the default locale defines every message (see locale lookup).
default_locale in manifest.json: required when _locales exists
Section titled “default_locale in manifest.json: required when _locales exists”If the package includes a _locales directory, manifest.json must set default_locale to the subdirectory name of your fallback language (for example "en").
Defines the default language of an extension that supports multiple locales. It is the name of the subdirectory in _locales that contains the default language for this extension.
— Google Chrome, Manifest - Default Locale
Important: If an extension has a _locales directory, the manifest must define “default_locale”.
— Google Chrome, chrome.i18n (MV2)
Extensions without _locales must omit default_locale entirely.
How to reference a message in manifest, CSS, and JavaScript
Section titled “How to reference a message in manifest, CSS, and JavaScript”Name each string in messages.json, then refer to that name—not the raw English text—in manifest, styles, and code:
| Context | Syntax |
|---|---|
manifest.json, CSS |
__MSG_messagename__ |
| JavaScript | browser.i18n.getMessage("messagename") or chrome.i18n.getMessage("messagename") |
Example from the interface i18n guide: set "default_title": "__MSG_tooltip__" on an action, with "default_locale": "en" and the string defined under _locales/en/messages.json.
messages.json format: message, description, and placeholders
Section titled “messages.json format: message, description, and placeholders”Each entry is keyed by the message name (the same identifier used in __MSG_…__ and getMessage()). Only "message" is required; "description" and "placeholders" are optional but valuable for translators.
The following code shows the supported fields for messages.json. Only the “name” and “message” fields are required.
— Google Chrome, Localization message formats
Message names: characters and reserved @@ keys
Section titled “Message names: characters and reserved @@ keys”The JSON key is the message name (case-insensitive). Allowed characters: A–Z, a–z, 0–9, _, and @. Do not define names starting with @@; those are reserved for predefined system messages.
The message field: literals, $$, and $placeholders$
Section titled “The message field: literals, $$, and $placeholders$”The message string holds the translated text. Refer to placeholders with $placeholder_name$ (case-insensitive). A literal dollar sign is written as $$ (for example "Amount (in $$)").
You can use $1, $2, … directly in the message, but the docs recommend named placeholders so translators and future you know what each slot means.
placeholders and getMessage() substitutions
Section titled “placeholders and getMessage() substitutions”Placeholders map named slots to fixed text or to substitution arguments passed into getMessage(). Each placeholder has content (often "$1") and ideally example for translators.
"error": { "message": "Error: $details$", "description": "Generic error template. Expects error parameter to be passed in.", "placeholders": { "details": { "content": "$1", "example": "Failed to fetch RSS feed." } }}In JavaScript:
status.innerText = chrome.i18n.getMessage("error", errorDetails);If a substitution index is missing, that part resolves to an empty string. Full field rules are in Localization message formats (MV3); the MV2 message format page describes the same schema.
getMessage(): API behavior, limits, and escapeLt
Section titled “getMessage(): API behavior, limits, and escapeLt”browser.i18n.getMessage(messageName, substitutions?, options?) returns the localized string for messageName.
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.
— Google Chrome, browser.i18n
- Substitutions: up to 9 strings per call when the message needs dynamic segments.
options.escapeLt(Chrome 79+): whentrue, escapes<in the translated message (not in substitutions) to<, useful if the string is inserted into HTML.
Wrong types or too many substitutions yield undefined, not a thrown error—worth checking during development.
Predefined messages: @@ui_locale, @@bidi_*, and @@extension_id
Section titled “Predefined messages: @@ui_locale, @@bidi_*, and @@extension_id”The platform injects special names you can use in CSS and JavaScript (not in manifest.json for @@extension_id):
| Message | Role |
|---|---|
@@extension_id |
Extension ID for chrome-extension:// URLs in CSS/JS |
@@ui_locale |
Current UI locale string |
@@bidi_dir |
ltr or rtl |
@@bidi_reversed_dir |
Opposite of @@bidi_dir |
@@bidi_start_edge |
left or right (start side for padding/margin) |
@@bidi_end_edge |
right or left (end side) |
The special message @@extension_id can be used in the CSS and JavaScript files, whether or not the extension or app is localized. This message doesn’t work in manifest files.
— Google Chrome, browser.i18n
Example for RTL-aware CSS:
div#header { padding-__MSG_@@bidi_start_edge__: 0; padding-__MSG_@@bidi_end_edge__: 1.5em;}Supported locale codes and Web Store alignment
Section titled “Supported locale codes and Web Store alignment”Pick locale folder names from the set Chrome supports (including regional variants such as en_GB, en_US, zh_CN). Locales such as en can cover multiple regional variants when you do not ship a more specific folder.
You can localize your extension to any locale that is supported by the Chrome Web Store. If your locale is not listed here, choose the closest alternative.
— Google Chrome, browser.i18n — Locales
The reference lists dozens of codes (ar, de, en, es_419, pt_BR, zh_TW, and others) on the same page.
How Chrome picks a string when a locale is missing messages
Section titled “How Chrome picks a string when a locale is missing messages”You do not need a complete translation in every _locales folder. Lookup order for a user’s UI language:
_locales/<user locale>/messages.json(for exampleen_GB)- If the locale contains
_, fall back to the language only (for exampleen) - Fall back to
default_localefrommanifest.json
As long as the default locale’s messages.json file has a value for every string, your extension or app will run no matter how sparse a translation is.
— Google Chrome, browser.i18n — Search for messages
That is why US English might show “Colors”, British English “Colours” from en_GB, and both might still show an extension name only present in en and default_locale Spanish.
Chrome Web Store listing: localize description, screenshots, and video
Section titled “Chrome Web Store listing: localize description, screenshots, and video”Extension UI i18n (_locales) is separate from store listing copy. After localizing the package, the Chrome Web Store listing dashboard lets you choose each language from a dropdown (matching _locales/LOCALE_CODE folders) and enter a detailed description per locale.
If you have localized your extension, you will be able to provide a description, screenshots, and promotional video in the locales your extension supports. The small tile and Marquee promo tile cannot be localized.
— Google Chrome, Complete your listing information
Repeat the locale selection to add localized screenshots and a localized promo video URL (for example YouTube in the target language). By default the item is listed in all regions; narrow distribution on the Distribution tab if the extension targets specific countries.
External install: supported_locales in the manifest
Section titled “External install: supported_locales in the manifest”For policies that install extensions only for certain browser languages, an external install manifest may list supported_locales. A parent code like "en" applies to all English variants (en-US, en-GB, …). If the user’s locale is not listed, the externally installed extension is uninstalled. Omit the field to allow any locale.
{ "external_update_url": "https://clients2.google.com/service/update2/crx", "supported_locales": [ "en", "fr", "de" ]}See Use alternative installation methods.
Test translations: change the browser UI language
Section titled “Test translations: change the browser UI language”To verify _locales, set Google Chrome’s UI language and reload the extension UI.
Windows: --lang shortcut (multiple languages at once)
Section titled “Windows: --lang shortcut (multiple languages at once)”-
Copy the desktop Chrome shortcut and rename it for the locale (for example
chrome-es). -
Set Target to include
--langand optionally--user-data-dir:path_to_chrome.exe --lang=es --user-data-dir=c:\chrome-profile-es -
Launch via that shortcut. Separate profile directories let you run several languages simultaneously; each profile needs its own extension install for testing.
Note: Specifying –user-data-dir is optional but handy. Having one data directory per locale lets you run the browser in several languages at the same time. A disadvantage is that because the locales’ data isn’t shared, you have to install your extension multiple times—once per locale
— Google Chrome, browser.i18n — Use a locale-specific shortcut
You can also change language via Chrome settings (Languages under font and language settings) and restart Chrome, as described in the same reference.
macOS, Linux, and ChromeOS
Section titled “macOS, Linux, and ChromeOS”- macOS: System Preferences → International → language and location → restart Chrome (browser.i18n).
- Linux: quit Chrome, then launch with
LANGUAGE=es ./chrome(replaceesand the binary path as needed). - ChromeOS: Settings → Languages and input → set display language → restart when prompted.
Common mistakes
Section titled “Common mistakes”- Shipping
_localeswithout"default_locale", or settingdefault_localewhen there is no_localesfolder. - Hard-coding UI strings in JS while only localizing the manifest.
- Using
@@extension_idinsidemanifest.json(not supported). - Defining custom keys starting with
@@. - Passing more than nine substitutions to
getMessage(), which returnsundefined. - Expecting partial locale files to work without a complete default
messages.json. - Confusing in-extension i18n with localized store listing assets (tiles that cannot be localized per locale).
How to check this on your site
Section titled “How to check this on your site”-
Confirm
manifest.jsonincludes"default_locale"if and only if_locales/exists, matching a real folder name (Default Locale). -
Load the unpacked extension, switch Chrome UI language using
--langor system language settings (browser.i18n), and confirm manifest fields, popups, and action titles show translated text. -
Deliberately remove one key from a non-default
messages.jsonand verify fallback to language-only thendefault_localebehavior. -
In the Chrome Web Store listing, step through each supported locale and confirm description and localized screenshots are filled in.
-
You can check automatically in Answerwell (our tool): https://answerwell.org/workspace
Report an error or ask a question
Section titled “Report an error or ask a question”If something on this page is wrong or unclear, email yimasynthetic@gmail.com with the page URL and the exact passage you are asking about, and we will correct or clarify it.