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

# Yerelleştirme

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

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

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

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

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

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

## Çevirilerin oluşturulması {#create-translation}

Çeviri oluşturmak için `i18n` adlı bir klasör oluşturun. Bu klasörde çeviriler JSON formatındaki dosyalarda saklanacaktır.

Örnek olarak, İngilizce ve Rusça dillerine karşılık gelen `en.json` ve `ru.json` dosyalarını oluşturalım.

![Dosya yapısının ekran görüntüsü: "fronts", "i18n", "input" ve "ysdk" klasör listesinin bir kısmı görülüyor. "i18n" klasöründe "en.json" ve "ru.json" dosyaları bulunur.](../../_images/defold/localization/files-create.webp)

İçeriği çeviri dosyalarına ekleyin:

{% list tabs %}

- en.json

    ```json showLineNumbers
    {
        "game": {
            "title": "Cool Game"
        },
        "button": "Button"
    }
    ```

- ru.json

    ```json showLineNumbers
    {
        "game": {
            "title": "Крутая игра"
        },
        "button": "Кнопка"
    }
    ```

{% endlist %}

## Çevirileri alma {#get-translation}

Belirli bir anahtarın değerini almak için `i18n.key(key)` yöntemini kullanabilirsiniz.

```lua
print(i18n.key("game.title")) -- "Cool Game"
```

Ayrıca, kullanıcı arayüzündeki seçilen düğümün içeriğini değiştiren yardımcı bir `i18n.gui(node_id, key)` yöntemi de bulunmaktadır.

`i18n.gui()` yöntemi sayesinde aşağıdaki işlemi kısaltabiliriz:

```lua
gui.set_text(gui.get_node("title_label"), i18n.key("game.title"))
```

Önce:

```lua
i18n.gui("title_label", "game.title")
```

### Bir oyunun yerelleştirilmesi örneği {#localization-example}

```lua showLineNumbers
local i18n = require('ysdk.i18n')

local function on_localize()
    i18n.gui("title_label", "game.title")
    i18n.gui("button_label", "button")
end

function init(self)
    i18n.on(on_localize)
end

function final(self)
    i18n.off(on_localize)
end
```

![Siyah ekranın ortasında "Cool" yazısı, hemen altında "Button" yazılı beyaz bir buton var.](../../_images/defold/localization/example.webp)

## Çeviri dilini değiştirme {#lang-change}

{% note info %}

i18n modülü, [ortam değişkenlerinden](https://yandex.com.tr/dev/games/doc/tr/sdk/defold/environment.md) kullanıcının diline karşılık gelen dili otomatik olarak başlatır.

Dili yalnızca, kullanıcı isteğiyle manuel olarak değiştirmek istediğinizde bu yöntemi kullanmanız önerilir.

{% endnote %}

Çeviri dilini değiştirmek için `i18n.set_language(code: string)` metodunu kullanabilirsiniz.

```lua showLineNumbers
function settings.change_language(code)
    i18n.set_language(code)
end
```

---


<!-- source: tr/_includes/sdk/button-git.md -->
<a href="https://github.com/yandex-games-plugins/defold">
  <span class="button">Depo</span>
</a>
<!-- endsource: tr/_includes/sdk/button-git.md -->
