Skip to main content

Localization API

The Localization API provides access to the buyer's language, currency, country, and timezone during checkout. Use this API to translate strings into the buyer's language; format numbers, currency, and dates; and adapt your extension to different regions.

translate() reads keys only from your extension's locale files. It doesn't have access to the shop's theme translations or other extensions' locale data.

  • Translate extension text: Define locale files and render translated strings, including dynamic values and pluralization.
  • Format numbers, currency, and dates: Display values formatted for the buyer's locale.
  • Adapt to the buyer's region: Read shopify.localization.country and shopify.localization.currency to adjust your extension's behavior for different regions.
  • Check the active extension language: Check which language your extension is actually rendering in to serve correct locale-specific content from your own backend.
Support
Targets (33)

Anchor to Properties and methodsProperties and methods

The shopify global object provides localization and internationalization capabilities for the current checkout. Access the following properties and methods on shopify to read the buyer's language, currency, country, and timezone, and to translate and format content. Available to purchase extension targets.

required

Utilities for translating strings, formatting currencies, numbers, and dates according to the buyer's locale. Use alongside localization to build fully localized extensions.

Anchor to localization
localization
required

The buyer's language, country, currency, and timezone context. For formatting and translation helpers, use the i18n object instead.


  • Always use locale files for user-facing text: Define all visible strings in locales/*.json and access them through shopify.i18n.translate(). Don't hardcode strings in your extension code.
  • Provide a default locale: Include a locales/en.default.json file as a fallback. Shopify uses the default locale when the buyer's language doesn't have a matching translation file.
  • Use formatNumber() for any displayed numbers: Avoid formatting numbers manually. shopify.i18n.formatNumber() applies the correct thousands separator, decimal separator, and currency formatting for the buyer's locale.

  • Translation files are static and loaded at extension startup. You can't update translations dynamically at runtime.

Was this page helpful?