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

Methods

getLanguage()

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

Syntax

Copy

Returns

2-letter language code in ISO 639-1 alpha-2 format. See Languages Available in Wix.

Example

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

Copy

getLocale()

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

Syntax

Copy

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.

See Languages Available in Wix.

Example

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

Copy
Did this help?