---
metadata:
  - name: generator
    content: Diplodoc Platform v5.52.0
alternate:
  - https://yandex.com/dev/games/doc/en/sdk/defold/localization.md
  - https://yandex.com/dev/games/doc/hi/sdk/defold/localization.md
  - https://yandex.com/dev/games/doc/ko/sdk/defold/localization.md
  - https://yandex.com/dev/games/doc/ru/sdk/defold/localization.md
  - https://yandex.com/dev/games/doc/tr/sdk/defold/localization.md
  - https://yandex.com/dev/games/doc/vi/sdk/defold/localization.md
  - https://yandex.com/dev/games/doc/zh/sdk/defold/localization.md
  - href: ko/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/dev/games/doc/ko/llms.txt

# 현지화

## 번역 생성

먼저, 번역 파일들이 저장될 `i18n` 폴더를 만드세요. 이 폴더에는 JSON 형식의 파일들이 들어갑니다. 이 파일들에 번역 내용이 저장됩니다.

예를 들어, 영어와 러시아어에 해당하는 `en.json`과 `ru.json` 파일을 만들어보겠습니다.

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

이제 파일에 어떤 내용이든 채워 넣어야 합니다:

{% list tabs %}

- en.json

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

- ru.json

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

{% endlist %}

## 번역 가져오기

특정 키의 값을 가져오려면 `i18n.localize(key)` 메서드를 사용하면 됩니다.

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

또한 보조 메서드인 `i18n.gui(node_id, key)`가 있어, 사용자 인터페이스에서 선택한 노드의 내용을 교체할 수 있습니다.

`i18n.gui()`를 사용하면 다음과 같이 코드를 간소화할 수 있습니다:

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

이전:

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

### 게임 현지화 예시

```lua
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.png)

## 언어 변경

{% note info "참고" %}

i18n 모듈은 [환경 변수](https://yandex.com/dev/games/doc/ko/sdk/defold/environment.md)에 설정된 사용자의 언어에 맞게 언어를 자동으로 초기화합니다.

이 메서드는 사용자가 직접 언어를 변경하고자 할 때만 사용하는 것을 권장합니다.

{% endnote %}

번역 언어를 변경하려면 `i18n.set_language(code: string)` 메서드를 사용할 수 있습니다.

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

---


<!-- source: ko/_includes/button-git-defold.md -->
<a href="https://github.com/yandex-games-plugins/defold">
  <span class="button">저장소</span>
</a>
<!-- endsource: ko/_includes/button-git-defold.md -->
