Skip to main content

Locale API

The Locale API provides access to the merchant's current locale information in IETF format, allowing you to internationalize your extension content and respond to locale changes in real time. The API enables both immediate locale access and dynamic updates when merchants change their language settings.

  • Internationalization: Display text, dates, and numbers in the merchant's preferred language.
  • Regional logic: Implement locale-specific logic like currency formatting or address validation.
  • Dynamic updates: Update interfaces when merchants change their language settings.
  • Localized content: Provide locale-aware product descriptions or receipt customizations.
Support
Targets (28)

The shopify global object provides the merchant's current locale information. Access the following properties on shopify to get locale data and subscribe to locale changes for content internationalization.

Anchor to current
current
<string>
required

Provides read-only access to the current IETF-formatted locale and allows subscribing to locale changes. The value property provides the current locale, and subscribe allows listening to changes. Use for internationalization, locale-specific formatting, and reactive updates when merchants change language settings.


  • Handle locale changes reactively: Use the subscribe method to automatically update your extension content when merchants change their language settings.
  • Implement proper formatting: Use the IETF locale format to implement proper date formatting, number formatting, currency display, and text direction based on the merchant's language and region preferences.
  • Cache localized content: Consider caching translated content and locale-specific formatting to improve performance, but ensure you invalidate caches when locale changes occur through subscription updates.
  • Provide fallback locale handling: Implement fallback behavior for unsupported locales or when localization resources are unavailable, defaulting to a supported language like English.

Was this page helpful?