Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: Update the Localization topic #7113

Merged
merged 1 commit into from
Oct 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading