# Multi-language Support

## Multi-language Configuration

The extension supports multi-language configuration, you can create a `<IANA Language Tags>.json` file in the `./locales/` folder, you can create a `<IANA language tag>.json` file, which will be automatically associated with the corresponding language and called when appropriate.

::: code-group

```json [zh-Hans.json]
{
	"Enter": "确定",
	"Cancel": "取消"
}
```

```json [en.json]
{
	"Enter": "Enter",
	"Cancel": "Cancel"
}
```

:::

If you need to get all the language labels supported by the current extension, you can call the [SYS_I18n.getAllSupportedLanguages()](../reference/pro-api.sys_i18n.getallsupportedlanguages) method, which will return an array of strings.

::: warning

Note that if your extension has two or more languages, it must include at least one of `en` or `zh-Hans` as a fallback language, otherwise you may encounter unexpected display errors.

:::

## Use of Multiple Languages within the Code

To use a multilingual system to display different text in different language environments, use the [SYS_I18n.text()](../reference/pro-api.sys_i18n.text) method.

[SYS_I18n.text()](../reference/pro-api.sys_i18n.text) method has a mandatory argument `tag`, which corresponds to the key name in the multilingual file, and the key value matched by that key name is the final displayed text.

You can specify the `namespace` parameter as the `uuid` of other extensions to call the multilingual configuration of other extensions.

Currently, EasyEDA Professional only supports a few languages by default, while the extension API supports a lot of additional languages, you can use the `language` parameter to adapt more languages for your extension, but you need to design your own logic and method to switch languages.

When translating a language, it is very likely that we will encounter a situation where we need to embed parameters into the text, because the syntax of each language is different and the position of the parameters in the text of the language may vary greatly, you can use a placeholder in the `${1}` format to indicate the parameters that need to be embedded and pass the parameters into the `arg` of the [SYS_I18n.text()](../reference/pro-api.sys_i18n.text) method within `arg`, so that when the specified text is displayed, the corresponding argument will be embedded in the text at the specified location.

::: tip

Language priority: current display language > system default language > the first language in the dataset that contains the text tag > text label (tag)

In addition to the above steps, you may need to know other [SYS_I18n](../reference/pro-api.sys_i18n) APIs to work more freely with multilingual content.

:::

## Translating Fields in extension.json

If you need to translate fields in `extension.json`, create a `<IANA language tag>.json` file in the `./locales/extensionJson/` folder.

Within that file, each `key` must be a `value` from `extension.json`, and each `value` in the translation file is the translated result.
