The short answer
To localize a Godot 4 game with gettext: write the English text in your scripts wrapped in tr(), extract every key into a .pot template, keep one .po file per language, add the .po files under Project Settings → Localization → Translations, and set the language at runtime with TranslationServer.set_locale(). Then add a test that fails when a key in the code is missing from the .po file, because that is the bug you will hit most.
Below is how that works in Tibblo, including the parts Godot leaves to you.
Tibblo's website is bilingual too: here is Tibblo in Turkish.
Why .po files and not CSV
Godot supports two formats: CSV tables and gettext .po files. CSV is fine for a few dozen strings. For thousands, .po wins:
- The key is the English text itself. No invented ids like
SHOP_TITLE_2. The code stays readable, and a missing translation falls back to English instead of showing an id. - Each entry records where it is used (
#: scripts/achievements.gd:30), which helps when a word needs context. - Standard tools understand it. Any translator or translation editor can open a
.pofile.
In Tibblo, English is the source text, locale/messages.pot is the template, and locale/tr.po holds the Turkish. Adding a language means adding one more .po file.
Extracting every string
Godot can generate a template from scenes and scripts, but a game built mostly in code has strings in places a generic extractor does not see. So Tibblo has its own small extract script. It collects:
- every literal inside
tr("...")andTranslationServer.translate("...")in the game's scripts, skipping test files; - every prose literal on a line marked with a
# i18ncomment; - the user-facing fields of the data catalogs: item names and descriptions, decoration names, each pet species' personality and fun facts.
It writes the .pot file and merges it into each .po: existing translations are kept, new keys are added empty, and keys the code no longer uses are dropped. Running it is part of every change that touches text.
When I first added a second language, most strings were not wrapped at all. A one-off helper found literals that read like prose and wrapped them in tr(). I reviewed every change by hand; it was a starting point, not a parser.
The const problem
GDScript constants are evaluated before any translation is loaded, so you cannot write const TITLE := tr("Speedy"). Tibblo keeps the English text in the constant, marks the line with # i18n so the extractor picks it up, and translates at the moment it is shown:
- the constant stores the key, for example a game mode's name;
- the screen calls
tr()on it when it builds the label.
The same rule applies to data: a catalog stores English, the UI translates. That also keeps saved games language-neutral, so switching the language never changes what is in a save file.
Placeholders, and where Turkish moves them
Strings with numbers use format placeholders: "%d of %d done" becomes "%d / %d tamamlandı", and "Done · +%d coins" becomes "Tamamlandı · +%d altın". The translation may reorder words around the placeholders, but it must keep every one of them, or the game crashes or shows the wrong number. A test compares the placeholders in each English key with its Turkish text.
One exception is built into that test: %%, a literal percent sign, may move. English writes "50%", Turkish writes "%50".
A small grammar bonus: Turkish keeps the noun singular after a number ("3 elma", three apple), so the Turkish file needs no plural forms at all.
Choosing the language at runtime
The settings screen offers three choices: Automatic, English and Türkçe. Each language is named in itself and never translated, so someone who cannot read the current language can still find their own.
Automatic is the default. It reads the device's language with OS.get_locale_language() and uses it if the game has it, and English otherwise. The game loads every .po file once with TranslationServer.add_translation(), resolves the saved choice to a locale and calls TranslationServer.set_locale(). Choosing a language saves it and rebuilds the screens, so nothing keeps the old language until a restart.
One trap for testing: on a Turkish computer, Automatic means Turkish, so tests that read English text would fail only on my machine. The test sandbox pins the "device" language to English, and the language tests opt back in.
Tests that catch untranslated text
Translation bugs are quiet. The game still runs; it just shows one English button on a Turkish screen. So the language test suite checks, headless:
- the
.pofile is complete and keeps every placeholder; - every
tr()key in the code exists in the.pofile, which catches the "forgot to run the extractor" mistake; - Automatic follows the device language;
- a real tap on Türkçe saves the choice and rebuilds the game in Turkish;
- then every room and screen is visited in Turkish and checked for two things: English words left on screen, and text cut off by its box.
The second check matters more than I expected. Turkish is often longer than its English source ("Backpack" is "Sırt çantası", "Unicorn" is "Tek boynuzlu at", "Scrapbooker" is "Albüm Meraklısı"), and a label that fits in English can overflow in Turkish.
One thing Godot cannot translate: iOS permission texts
iOS shows some texts from the app's Info.plist, such as the app name and permission descriptions. Godot's iOS export cannot localize them and leaves the Turkish InfoPlist.strings empty. Tibblo keeps a Turkish InfoPlist.strings in the repository, and the iOS release script copies it into the exported project's tr.lproj folder before archiving.
Common questions
Should translation keys be English text or ids?
For a game written by one person, English text. The code stays readable and a missing translation falls back to real words. Ids pay off when many translators need stable keys while the English copy keeps changing.
Why does tr() not work in a const?
Constants are evaluated when the script loads, before a locale is set. Store the English key in the constant and call tr() where the text is shown.
How do I follow the device language in Godot 4?
Read OS.get_locale_language(), use it if you have that translation, fall back to English, and let the player override it in settings.
What I learned
The runtime is the easy part. Godot's TranslationServer just works. The real work is keeping thousands of strings in step with the code.
Automate extraction and test it. A test that fails on any key missing from the .po file turned a recurring bug into a non-event.
Test the translated game, not only the file. A complete .po file can still produce a screen with clipped labels. Visiting every screen in the other language is what catches it.