---
metadata:
  - name: generator
    content: Diplodoc Platform v5.52.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: tr/sdk/defold/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.tr/dev/games/doc/tr/llms.txt

# 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}

Öncelikle, çevirilerinizin saklanacağı JSON formatındaki dosyaların yer alacağı `i18n` adlı bir klasör oluşturun.

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

![](../../_images/defold/localization/files-create.webp)

Şimdi, dosyalarımızı bir miktar içerikle doldurma zamanı:

{% 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.localize(key)` metodunu 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", "game.title")
end

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

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

![](../../_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/button-git.md -->
<a href="https://github.com/yandex-games-plugins/defold">
  <span class="button">Depo</span>
</a>
<!-- endsource: tr/_includes/button-git.md -->
