Manage the current locale used by the SDK for the current device.
The language
and country
values are always to the following standards:
language
: the ISO 639-1 language codecountry
: the ISO 3166-1 alpha-2 country code
Example
const sdk = await UA
// override the country and language
await sdk.set({country: 'FR', language: 'fr'})
Members
clear :Promise.<void>
Clears any overridden values in the current locale, and returns it to the browser default.
Type:
-
Promise.<void>
Example
const sdk = await UA
await sdk.locale.clear()
get :Promise.<ResolvedLocale>
Gets the current locale. Note that in some browsers country may be null
.
Type:
-
Promise.<ResolvedLocale>
Example
const sdk = await UA
const {country, language} = await sdk.locale.get()
console.log(`language: ${language}, country: ${country}`)
set :Promise.<void>
Overrides the current locale.
Type:
-
Promise.<void>
Example
const sdk = await UA
// override the country and language
await sdk.locale.set({country: 'FR', language: 'fr'})
// you can also choose to override one property while leaving the other
// at its current value
await sdk.locale.set({language: 'fr'})
// if you'd like to clear one property while retaining another, pass `null`
await sdk.locale.set({language: 'fr', country: null})