---
metadata:
  - name: generator
    content: Diplodoc Platform v5.54.4
alternate:
  - https://yandex.com/dev/games/doc/en/sdk/cocos/localization.md
  - https://yandex.com/dev/games/doc/hi/sdk/cocos/localization.md
  - https://yandex.com/dev/games/doc/ko/sdk/cocos/localization.md
  - https://yandex.com/dev/games/doc/ru/sdk/cocos/localization.md
  - https://yandex.com/dev/games/doc/tr/sdk/cocos/localization.md
  - https://yandex.com/dev/games/doc/vi/sdk/cocos/localization.md
  - https://yandex.com/dev/games/doc/zh/sdk/cocos/localization.md
  - href: en/sdk/cocos/localization.md
    type: text/markdown
    title: Markdown version
  - href: ../../llms.txt
    type: text/markdown
    title: llms.txt
---
> **Documentation Index:** Fetch the complete configuration index at https://yandex.com/dev/games/doc/en/llms.txt

# Localization

<!-- source: en/_includes/script-common.md -->
<!-- source: en/_includes/script/index-js.md -->

<!-- endsource: en/_includes/script/index-js.md -->

<!-- source: en/_includes/script/requirements-js.md -->

<!-- endsource: en/_includes/script/requirements-js.md -->

<!-- source: en/_includes/script/image-modal-js.md -->

<!-- endsource: en/_includes/script/image-modal-js.md -->
<!-- endsource: en/_includes/script-common.md -->

## Localization Editor {#localization-editor}

Translations are stored in JSON format within the project, and we strongly recommend using it for editing them.

After installing the plugin, in the Yandex Games SDK section, click on the **Localization Editor** option.

At first, the editor will look quite empty. This is because you need to create your first localization, which can be done by clicking the **Create** button in the upper left corner.

![](../../_images/cocos/localization/create-loc.webp)

A modal window will appear where you can select a language. Once finished, press **Create JSON file**.

![](../../_images/cocos/localization/create-json.webp)

For example, let's select _English (en)_ and enter the following in the editor.

```json showLineNumbers
{
  "title": "best game in the world 2"
}
```

Press the **Save** button to save your localization and test it in the game.

![](../../_images/cocos/localization/save-loc.webp)

### Applying Your Localization {#localization-use}

There are two ways to apply localization: using the `l10n.t()` method or through the smart localization component.

#### Method l10n.t {#ll0nt-method}

Let's first try using the `l10n.t()` method. Create a new component and insert the following:

```tsx showLineNumbers
import { _decorator, Component, Label } from "cc";
import { l10n } from "db://yandex-games-sdk/ysdk";
const { ccclass, requireComponent } = _decorator;

@ccclass("ButtonLocalizationTest") // Component name.
@requireComponent(Label) // Dependency on the Label component.
export class ButtonLocalizationTest extends Component {
  onLoad() {
    const label = this.getComponent(Label); // Retrieve the Label component.
    label.string = l10n.t("title"); // Set the text of the Label based on a previously specified key.
  }
}
```

After you create a node with a Label component on the scene, you can localize it by dragging the component to the node.

![](../../_images/cocos/localization/label.gif)

#### The Ready-made Component L10nLabel {#l10nlabel}

If you don't want to reinvent the wheel, the plugin has a ready-made component that displays the key directly in the editor. Compiling the project to view changes is not required, as it automatically updates when changes are made in the translation editor.

Click on the **Add Component** button for the node you are interested in, scroll to the **YandexGamesSDK** group, and select **L10nLabel**.

![](../../_images/cocos/localization/l10n-label.gif)

Now you can enter your key in the **Key** field and enjoy the result. No matter how you change the localization, changes will be immediately visible here.

![](../../_images/cocos/localization/enter-key.gif)


---


<!-- source: en/_includes/button-git.md -->
<a href="https://github.com/yandex-games-plugins/cocos">
  <span class="button">Repository</span>
</a>
<!-- endsource: en/_includes/button-git.md -->
