Localization
Translating a game into a few major languages can open it to many more players, but only if the code is ready for it. The expensive part of localization is rarely the translation; it's finding every hard-coded string, every UI box that overflows in German, every sentence built by gluing words together, and every font that has no Japanese glyphs. Internationalization (i18n) is making the game ready; localization (l10n) is doing each language. Do the first from day one, even if you ship in one language.
The rules of localizable code
- No user-visible text in code. Every string is a key looked up in a string table:
tr("MENU_START"), not"Start". - No concatenation.
"You found " + n + " coins"can't be translated, because word order differs between languages. Use whole sentences with placeholders:"You found {count} coins". - Plurals are rules, not
if n == 1. English has two forms; Polish has more, Japanese has one. Use the CLDR plural categories (one,few,many,other, …) that localization libraries implement. - UI must grow. Translations are often 30% longer than English, and much more for short labels. Use auto-sizing layouts, not fixed boxes.
- Fonts must cover the alphabet. Chinese, Japanese and Korean need fonts with thousands of glyphs (and engines that generate glyph atlases on demand); Arabic and Hebrew need right-to-left layout and shaping.
- Numbers, dates and currency are formatted per locale (
1,234.5vs1.234,5). - Text in images (logos aside) must be avoidable or replaceable per language.
Engine support: Unity's Localization package (string tables, smart strings with plurals, asset tables), Unreal's Localization Dashboard (gathers FText, exports PO files for translators), and Godot's TranslationServer with CSV or gettext PO files and tr() on any node. Translators usually work in CSV, PO (gettext) or XLIFF files, or in a translation-management platform.
A string table with placeholders and plurals
A minimal implementation shows how the pieces fit together:
TABLES = {
"en": {
"MENU_START": "Start game",
"COINS_FOUND": {"one": "You found {count} coin", "other": "You found {count} coins"},
"WELCOME": "Welcome back, {name}!",
},
"de": {
"MENU_START": "Spiel starten",
"COINS_FOUND": {"one": "Du hast {count} Münze gefunden", "other": "Du hast {count} Münzen gefunden"},
"WELCOME": "Willkommen zurück, {name}!",
},
"pl": {
"MENU_START": "Rozpocznij grę",
"COINS_FOUND": {"one": "Znaleziono {count} monetę", "few": "Znaleziono {count} monety",
"many": "Znaleziono {count} monet"},
},
}
def plural_category(lang, n):
if lang == "pl": # CLDR rules for integers
if n == 1:
return "one"
if n % 10 in (2, 3, 4) and n % 100 not in (12, 13, 14):
return "few"
return "many"
return "one" if n == 1 else "other" # English, German
def tr(lang, key, **args):
entry = TABLES[lang].get(key) or TABLES["en"].get(key) # fall back to English
if entry is None:
return f"#{key}#" # visible placeholder for missing keys
if isinstance(entry, dict):
entry = entry[plural_category(lang, args["count"])]
return entry.format(**args)
for lang in ("en", "de", "pl"):
print(lang, "|", tr(lang, "MENU_START"), "|", tr(lang, "WELCOME", name="Ada"))
print(" ", " / ".join(tr(lang, "COINS_FOUND", count=n) for n in (1, 3, 5, 22)))
print(tr("en", "MENU_OPTIONS"))en | Start game | Welcome back, Ada!
You found 1 coin / You found 3 coins / You found 5 coins / You found 22 coins
de | Spiel starten | Willkommen zurück, Ada!
Du hast 1 Münze gefunden / Du hast 3 Münzen gefunden / Du hast 5 Münzen gefunden / Du hast 22 Münzen gefunden
pl | Rozpocznij grę | Welcome back, Ada!
Znaleziono 1 monetę / Znaleziono 3 monety / Znaleziono 5 monet / Znaleziono 22 monety
#MENU_OPTIONS#
Polish shows why n == 1 isn't enough: 3 and 22 use one form, 5 another. The missing Polish WELCOME falls back to English, and a missing key shows as #MENU_OPTIONS#, loudly, so testers notice.
Pseudo-localization
You don't need translations to find localization bugs. Pseudo-localization generates a fake language from English that is still readable but exercises everything that breaks: accented characters (font coverage), extra length (layout), and brackets that show where a string was cut off or concatenated:
ACCENTED = str.maketrans("aceinosuyACEINOSUY", "àçéîñöšûýÀÇÉÎÑÖŠÛÝ")
def pseudo(text, expand=0.4):
out, i = [], 0
while i < len(text): # keep {placeholders} intact
if text[i] == "{":
j = text.index("}", i)
out.append(text[i:j + 1])
i = j + 1
else:
out.append(text[i].translate(ACCENTED))
i += 1
body = "".join(out)
padding = "~" * round(len(text) * expand)
return f"[{body}{padding}]"
strings = {"MENU_START": "Start game", "MENU_QUIT": "Quit", "WELCOME": "Welcome back, {name}!",
"HINT_DASH": "Press {key} to dash through enemies"}
BUTTON_WIDTH = 14 # characters that fit in the menu button
for key, text in strings.items():
p = pseudo(text)
warn = " <- overflows the button" if key.startswith("MENU") and len(p) > BUTTON_WIDTH else ""
print(f"{key:<11} {p}{warn}")MENU_START [Štàrt gàmé~~~~] <- overflows the button
MENU_QUIT [Qûît~~]
WELCOME [Wélçömé bàçk, {name}!~~~~~~~~]
HINT_DASH [Préšš {key} tö dàšh thröûgh éñémîéš~~~~~~~~~~~~~~]
Run the whole game in the pseudo-locale before sending text to translators: every un-bracketed string on screen is a hard-coded string, every ~ cut off is a layout that will break in German, and every missing glyph shows up as a box.
Practical workflow
- Keep the source strings (with context notes for translators: "button, max 14 characters", "{name} is the player's name") in the repository.
- Export new and changed strings to translators in their format; import the results; never edit translations by hand in code.
- Check in CI: every key exists in every shipped language (or is deliberately English), placeholders match between source and translation, no line exceeds its limit.
- Test each language in the build, ideally with a native speaker (linguistic QA): translations without context are often correct words in the wrong place.
- Localize the store page too; it's the first thing a player in that language sees (Store Page Assets).
Test yourself
Why is "You found " + n + " coins" hard to localize?
- It's slow
- Word order and plural forms differ between languages, so the sentence must be one translatable string with a placeholder
- Numbers can't be translated
- It uses too much memory
What is pseudo-localization for?
- Machine translation
- Finding hard-coded strings, layout overflow and font gaps before real translations exist
- Compressing text
- Testing audio
In Polish, which plural category does 22 use according to CLDR?
- one
- few
- many
- other