Overview
Tested with: Godot 4.3+
Reaching players worldwide requires localization (i18n: internationalization). If you need to "display UI text in Japanese, English, and Korean" or "automatically switch based on player language settings," Godot's TranslationServer provides the solution.
Localization might sound complex, but Godot makes it surprisingly simple. There are essentially three steps -- prepare translation data in a CSV, register it in the project, and call tr() in your code. That's all it takes to support any number of languages without changing your code.
This article covers practical implementation from managing translations with CSV files to dynamic language switching and leveraging placeholders, using Japanese, English, and Korean as a three-language example.
How TranslationServer Works
Let's start with the big picture. TranslationServer maps translation keys to language-specific text. Instead of hardcoding strings like "Start Game" or "ゲームスタート" directly in your code, you use common keys like START_GAME and retrieve the appropriate text at runtime based on the current language.
Why is this approach necessary? If you hardcode text in one language, supporting another means modifying your code. As you add 3, 5, or more languages, the number of changes becomes unmanageable and error-prone. Translation keys let you add languages without touching the code at all.
Basic flow:
- Define a mapping of
key, Japanese, English, Koreanentries in a translation file (e.g., CSV) - Register the translation file in Project Settings
- Call
tr("key")in your code to get the text for the current language
Example:
# When the current language is Japanese
tr("START_GAME") # -> "