Skip to main content

Localization

The APIs for localizing your extension.

The base API object provided to purchase extension targets.

required

Utilities for translating content and formatting values according to the current localization of the checkout.

Refer to localization examples for more information.

Anchor to localization
localization
required

The details about the location, language, and currency of the customer. For utilities to easily format and translate content based on these details, you can use the i18n object instead.

Returns the currency of the checkout.

Currency

isoCode

The ISO-4217 code for this currency.

Anchor to useExtensionLanguage
useExtensionLanguage()

Returns the buyer's language, as supported by the extension.

Language

isoCode
string

The BCP-47 language tag. It may contain a dash followed by an ISO 3166-1 alpha-2 region code.

Returns the current language of the checkout, and automatically re-renders your component if the language changes.

Language

isoCode
string

The BCP-47 language tag. It may contain a dash followed by an ISO 3166-1 alpha-2 region code.

Anchor to useLocalizationCountry
useLocalizationCountry()

Returns the country of the checkout, and automatically re-renders your component if the country changes.

| undefined

Anchor to useLocalizationMarket
useLocalizationMarket()

Returns the market of the checkout, and automatically re-renders your component if it changes.

| undefined

Returns the time zone of the checkout, and automatically re-renders your component if the time zone changes.

Timezone

'Africa/Abidjan' | 'Africa/Algiers' | 'Africa/Bissau' | 'Africa/Cairo' | 'Africa/Casablanca' | 'Africa/Ceuta' | 'Africa/El_Aaiun' | 'Africa/Johannesburg' | 'Africa/Juba' | 'Africa/Khartoum' | 'Africa/Lagos' | 'Africa/Maputo' | 'Africa/Monrovia' | 'Africa/Nairobi' | 'Africa/Ndjamena' | 'Africa/Sao_Tome' | 'Africa/Tripoli' | 'Africa/Tunis' | 'Africa/Windhoek' | 'America/Adak' | 'America/Anchorage' | 'America/Araguaina' | 'America/Argentina/Buenos_

Returns the I18nTranslate interface used to translate strings.

I18nTranslate

This returns a translated string matching a key in a locale file.

Examples
/* See the locales/en.default.json tab for the translation keys and values for this example */
import {
reactExtension,
Text,
useTranslate,
} from '@shopify/ui-extensions-react/checkout';

export default reactExtension(
'purchase.checkout.block.render',
() => <Extension />,
);

function Extension() {
const translate = useTranslate();
return (
<Text>{translate('welcomeMessage')}</Text>
);
}
Was this page helpful?