Localization

You can override the user’s default locale to utilize localization for a specific language.

See Localization in our message content documentation for more details.

Overriding locale

Airship uses the user’s LocaleThe combination of a language and country. A user’s locale is determined by their device settings. for various locale-sensitive tasks, including selecting the language for messages and reporting for analytics. The SDK can override the locale so that Airship uses a different locale than the browser’s current locale.

In the Web SDK, a locale can be set before or after creating a channel. If set, it overrides the browser’s locale information. See the Web SDK reference for the full Locale Manager.

Setting the locale language:
const sdk = await UA
await sdk.locale.set({language: 'fr'})
Setting the locale country:
const sdk = await UA
await sdk.locale.set({country: 'FR'})
Clear the locale override:
const sdk = await UA
await sdk.locale.clear()
Setting/replacing locale:
const sdk = await UA
// replace just the language
await sdk.locale.set({language :'fr'})
// replace just the country
await sdk.locale.set({country :'FR'})
// replace both
await sdk.locale.set({country :'fr', language :'fr'})

Overrides can be reset by passing null as the value for either the country oder language key to set().

Resetting locale:
const sdk = await UA
await sdk.locale.set({country: null, language: 'fr'})

You may also retrieve the current resolved locale; this will coalesce the values provided by the browser with the current override values that you have set:

Getting the current locale settings:
const sdk = await UA
const {language, country} = await sdk.locale.get()
 Note

Not all browser and OS combinations will provide a country, so the value of country may be null.