LocalizationAPI
The API for localizing your extension.
Anchor to standardapiStandardApi
The base API object provided to this and other customer-account
extension targets.
Utilities for translating content and formatting values according to the current localization
of the user.
Details about the language of the buyer.
Anchor to useLanguageuse Language()
Returns the buyer's language, as supported by the extension. If the buyer's actual language is not supported by the extension, it will return the fallback locale used for translations.
Language
The BCP-47 language tag. It may contain a dash followed by an ISO 3166-1 alpha-2 region code.
Anchor to useLocalizationCountryuse Localization Country()
Returns the country of the buyer's current session, and automatically re-renders your component if the country changes.
Anchor to useExtensionLanguageuse Extension Language()
Returns the language the buyer sees in the customer account hub.
Language
The BCP-47 language tag. It may contain a dash followed by an ISO 3166-1 alpha-2 region code.
Anchor to useI18nuse I18n()
Returns utilities for translating content and formatting values according to the current localization of the user.
Anchor to useI18n-returnsReturns
I18n
Returns a localized currency value.
This function behaves like the standard with a style of
currency
applied. It uses the buyer's locale by default.
Returns a localized date value.
This function behaves like the standard and uses the buyer's locale by default. Formatting options can be passed in as options.
Returns a localized number.
This function behaves like the standard with a style of
decimal
applied. It uses the buyer's locale by default.
Returns translated content in the buyer's locale, as supported by the extension.
options.count
is a special numeric value used in pluralization.- The other option keys and values are treated as replacements for interpolation.
- If the replacements are all primitives, then
translate()
returns a single string. - If replacements contain UI components, then
translate()
returns an array of elements.
Anchor to useTranslateuse Translate()
Returns the interface used to translate strings.
I18nTranslate
Translating strings
Anchor to examplesExamples
Anchor to example-getting-the-country-of-the-customerGetting the country of the customer
You can access the current country of a customer to implement country specific logic.
Anchor to example-translating-strings-with-pluralizationTranslating strings with pluralization
You can use the count option in the translate method to get a pluralized string based on the current locale.