Introduction

A multilingual site is a site that is set up to display in more than one language. To learn more about enabling multilingual functionality in a site, see About Wix Multilingual.

Did this help?

Setup

@wix/site-window

To use the Multilingual API, install the @wix/site-window package.

Install the package

Follow the installation instructions for your development environment.

Development environmentInstallation method
Wix sites (editor or IDE)Use the package manager.
Wix sites (local IDE)Run wix install @wix/site-window using the Wix CLI.
Blocks appsUse the same installation method as Wix sites.
CLI and self-hosted appsRun npm install @wix/site-window or yarn add @wix/site-window.

Import the package

To import the package in your code:

Copy
import { multilingual } from "@wix/site-window";
Did this help?

currentLanguage( )


Sets or gets a site's current display language.

Setting the currentLanguage property changes a site's display language. The current page is reloaded in the newly set language.

Set the current language using a two-letter language code. The code must represent one of the languages set to show on a site. You can retrieve a site's languages and corresponding language codes using the siteLanguages property.

Getting the currentLanguage property gets the two-letter language code of a site's current display language.

Method Declaration
Copy
function currentLanguage(): Promise<string>;
Request
This method does not take any parameters
Returns
Return Type:Promise<string>
JavaScript
import { multilingual } from "@wix/site-window"; // ... let language = await multilingual.currentLanguage; // "en"
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?

isEnabled( )


Gets whether a site has been set up to be shown in multiple languages.

Method Declaration
Copy
function isEnabled(): Promise<boolean>;
Request
This method does not take any parameters
Returns
Return Type:Promise<boolean>
Get whether a site is set up to be shown in multiple languages
JavaScript
import { multilingual } from "@wix/site-window"; // ... let isEnabled = await multilingual.isEnabled(); // true
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?

siteLanguages( )


Gets information about a site's languages.

The siteLanguages property returns an array of SiteLanguage objects containing information about all the languages that a site is set to display in.

Method Declaration
Copy
function siteLanguages(): Promise<Array<SiteLanguage>>;
Request
This method does not take any parameters
Returns
Return Type:Promise<Array<SiteLanguage>>
JavaScript
import { multilingual } from "@wix/site-window"; // ... let languages = await multilingual.siteLanguages(); /* languages is: * [ * { * "name": "English", * "locale": "en-us", * "languageCode": "en", * "countryCode": "USA", * "isPrimaryLanguage": true * }, { * "name": "Spanish", * "locale": "es-es", * "languageCode": "es", * "countryCode": "ESP", * "isPrimaryLanguage": false * }, { * "name": "Chinese", * "locale": "zh-cn", * "languageCode": "zh", * "countryCode": "CHN", * "isPrimaryLanguage": false * } * ] */
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?