i18n

The i18n submodule allows the code in an app's frontend interfaces to access the active language and locale settings for each interface. This allows apps to render their text in the same language and locale that the Wix user has chosen for the site.

When you are localizing your app, it is important to retrieve the localization settings for each extension's interface. For example, dashboard extensions should render text in the Wix user's account language, but site extensions should render text in the site's language.

See also:

Import statement

Copy
1

Methods

getLanguage()

Retrieves the language setting for the app extension that calls the function.

Syntax

Copy
1

Returns

2-letter language code in ISO 639-1 alpha-2 format.

Example

Set a string to Spanish if the site's language is set to Spanish. Otherwise, the string's language defaults to English.

Copy
1

getLocale()

Retrieves the locale setting for the app extension that calls the function.

Syntax

Copy
1

Returns

Locale in IETF BCP 47 language tag format.

Typically, this is a lowercase 2-letter language code, followed by a hyphen, followed by an uppercase 2-letter country code. For example, en-US for U.S. English, and de-DE for Germany German.

Example

Save the current date and time as a variable in the date format of the site's locale.

Copy
1
Was this helpful?
Yes
No