Skip to content

Commit

Permalink
Docs: Update the Localization topic (#7113)
Browse files Browse the repository at this point in the history
  • Loading branch information
RomanTsukanov committed Oct 10, 2023
1 parent 2ba9115 commit b1e59b1
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions docs/survey-localization.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ You can also create new dictionaries for unsupported languages. Use English as a

### Enable Localization and Switch Between Locales

The localization engine that works with dictionaries is available as a separate script/module. Reference this script in the `<head>` tag of your page or import this module into the component that renders your survey:
The localization engine that works with dictionaries is available as a separate script/module. This script/module imports dictionaries for all languages. Reference this script in the `<head>` tag of your page or import this module into the component that renders your survey:

```html
<script src="https://unpkg.com/survey-core/survey.i18n.min.js"></script>
Expand All @@ -33,11 +33,25 @@ The localization engine that works with dictionaries is available as a separate
import "survey-core/survey.i18n";
```

The default language for UI elements is English. To select another language, use the Survey's [`locale`](https://surveyjs.io/Documentation/Library?id=surveymodel#locale) property. For example, the following code translates the survey UI to French:
Since SurveyJS v1.9.112, you may reference or import only the languages you need, as shown below:

```html
<script src="https://unpkg.com/survey-core/i18n/french.js"></script>
<script src="https://unpkg.com/survey-core/i18n/german.js"></script>
<script src="https://unpkg.com/survey-core/i18n/italian.js"></script>
```

```js
import "survey-core/i18n/french";
import "survey-core/i18n/german";
import "survey-core/i18n/italian";
```

The default language for UI elements is English. To select another language, use `SurveyModel`'s [`locale`](https://surveyjs.io/Documentation/Library?id=surveymodel#locale) property. For example, the following code translates the survey UI to French:

```js
import { Model } from "survey-core";
import "survey-core/survey.i18n";
import "survey-core/i18n/french";
const surveyJson = { ... };
const survey = new Model(surveyJson);

Expand Down Expand Up @@ -84,6 +98,7 @@ If any translation strings are missing in your custom locale, they will be taken

```js
import { Model, surveyLocalization } from "survey-core";
import "survey-core/i18n/french";

surveyLocalization.defaultLocale = "fr";

Expand Down

0 comments on commit b1e59b1

Please sign in to comment.