Skip to main content
Extension.js discovers locale files next to your manifest and validates that each declared locale has a messages.json. It emits locale JSON assets into the browser-specific build. During development, it picks up edits to any locale file without a full restart.

Template example

action-locales

action-locales template screenshot See localized extension metadata and UI strings with _locales support.
Repository: extension-js/examples/action-locales

Locale capabilities

Expected structure

default_locale in manifest.json should map to an existing _locales/<default>/messages.json.

Sample locales declaration in manifest.json

Here is how to declare locales in manifest.json:
You would then include JSON files for each locale inside the _locales folder:

Sample messages.json file

Example messages.json file for translations:

Output path

Extension.js emits locale JSON files under:

Development behavior

  • Extension.js adds locale JSON files to compilation dependencies and watches them.
  • Locale changes trigger extension reload behavior (hard reload), not component-style hot module replacement (HMR).
  • Extension.js fails validation with actionable diagnostics when required locale files are missing or invalid.

Validation behavior

Extension.js validates:
  • default_locale presence when the project uses _locales
  • Existence of _locales/<default>/messages.json
  • JSON validity for locale files
  • __MSG_*__ references in manifest against default locale keys

Troubleshooting missing locale keys

If your manifest uses __MSG_extension_description__, ensure the default locale file contains extension_description:
If the default locale does not define the key, Extension.js surfaces a diagnostic explaining the mismatch.

Best practices

  • Keep messages.json keys consistent across locales.
  • Update default locale first, then propagate keys to other locales.
  • Validate locale JSON in continuous integration (CI) to catch malformed files before packaging.
  • Keep locale files close to manifest (manifestDir/_locales) for predictable resolution.

Next steps