Skip to main content
JavaScript and TypeScript locale modules keep translation catalogs in source files. Hyperlocalise supports the module shapes documented below; this is locale-file translation, not arbitrary application-code translation. Supported extensions: .js, .jsx, .mjs, .cjs, .ts, .tsx, .mts, .cts.

Source file

Save this example as locales/en-US/messages.ts.

Configure your files

Use this i18n.yml for the example, or add its file mapping to your existing bucket. See path templates for other layouts.

Translate

Install the CLI and set OPENAI_API_KEY in your project’s .env.local or shell. You can also configure another AI provider.
The dry run previews the work. The second command writes translations to the configured target path and updates the lockfile.

Behavior and limitations

  • Supports static locale objects exported with export default, export const, or module.exports, including a static variable followed by a default export.
  • Nested objects and string arrays are supported. Strict FormatJS message objects can include defaultMessage and description.
  • Imports, comments, export syntax, and unrelated module text are preserved. Only message string literals are replaced.
  • Dynamic values, computed keys, spreads, multiple exported locale objects, and interpolated template literals are rejected. These are locale modules, not arbitrary application source files.

Next steps