godot-i18n
Skill8 starsChanged 5 months agoMITView on GitHub
Localization patterns for Godot 4.x: TranslationServer, CSV/PO/JSON translation formats, runtime language switching, RTL text support, font fallback chains, and pluralization. Use when implementing internationalization in Godot games.
In this repository23 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- godot-47-migrationSkill
- godot-animationSkill
- godot-architectureSkill
- godot-audioSkill
- godot-brainstormingSkill
- godot-code-reviewSkill
- godot-csharp-patternsSkill
- godot-debuggingSkill
- godot-dialog-systemsSkill
- godot-gdscript-patternsSkill
- godot-headless-workflowSkill
- godot-inputSkill
- godot-inventory-economySkill
- godot-networkingSkill
- godot-performanceSkill
- godot-physicsSkill
- godot-project-setupSkill
- godot-save-systemsSkill
- godot-shaders-vfxSkill
- godot-state-managementSkill
- godot-uiSkill
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 1 is distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 46
Use the editor: Project → Tools → Translation to create .csv files, then export as .translation.
- Distinctive: line 226
When the MCP bridge is running (Phase 2), these tools can inspect and modify your project live:
≈ “Common” is an estimate: at least 1 in 5 of the 364,980 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Localization in Godot
Patterns for internationalizing Godot games.
TranslationServer Basics
Godot's built-in translation system uses .translation files (CSV-based):
# Mark strings for translation with _() shorthand
func _ready():
$Label.text = tr("Hello, Player!")
$Button.text = tr("Start Game")
# tr() calls TranslationServer.translate() internally
# Strings are looked up in loaded .translation resourcesCreating Translation Files
Use the editor: Project → Tools → Translation to create .csv files, then export as .translation.
Or create CSV manually:
msgid "Hello, Player!"
msgstr "¡Hola, Jugador!"
msgid "Start Game"
msgstr "Comenzar Juego"
msgid "Score: {0}"
msgstr "Puntuación: {0}"Registering Translations
In Project Settings → Locale → Configured Locales, add supported languages (e.g., es, fr, ja).
Runtime Language Switching
class_name LanguageManager extends Node
signal language_changed(locale: String)
var available_locales: Array[String] = ["en", "es", "fr", "ja"]
var current_locale: String = "en"
func set_language(locale: String) -> void:
if not available_locales.has(locale):
push_error("LanguageManager: Unsupported locale '%s'" % locale)
return
TranslationServer.set_locale(locale)
current_locale = locale
language_changed.emit(locale)
_notify_ui_update()
func _notify_ui_update() -> void:
# Re-tr() all UI labels that need updating
# Connect to language_changed signal in UI nodes
pass
# Save/restore preference
func _ready() -> void:
var saved = ConfigFile.new()
if saved.load("user://settings.cfg") == OK:
var locale = saved.get_value("general", "language", "en")
set_language(locale)
func _save_preference() -> void:
var config = ConfigFile.new()
config.load("user://settings.cfg")
config.set_value("general", "language", current_locale)
config.save("user://settings.cfg")Language Selector UI
# LanguageSelector.gd — attached to OptionButton
extends OptionButton
func _ready():
for locale in LanguageManager.available_locales:
var display_name = TranslationServer.get_locale_name(locale)
add_item(display_name, locale)
selected = LanguageManager.available_locales.find(LanguageManager.current_locale)
item_selected.connect(LanguageManager.set_language)Pluralization
Godot supports plural forms via trn():
# trn(singular, plural, count)
func show_item_count(count: int):
$Label.text = trn("You have {0} item.", "You have {0} items.", count) % count
# For complex plurals (Slavic languages with 3+ forms), use custom logic
func get_plural_string(msgid_singular: String, msgid_plural: String, n: int) -> String:
# Godot handles plural forms via .po format plural rules
return trn(msgid_singular, msgid_plural, n)RTL Text Support
For Arabic, Hebrew, and other right-to-left languages:
# In Label or RichTextLabel:
$Label.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
$Label.text_direction = TextServer.DIRECTION_RTL
$Label.alignment = HORIZONTAL_ALIGNMENT_RIGHT
# For mixed LTR/RTL content, use RichTextLabel with bbcode
$RichTextLabel.text = "[rtl]مرحبا[/rtl] [ltr]Hello[/ltr]"RTL-Aware UI Layout
# Container layouts flip automatically with RTL
# Use Control.layout_mode for proper RTL support:
$PanelContainer.set_anchors_preset(Control.PRESET_FULL_RECT)
# For manual positioning, mirror anchors:
func mirror_for_rtl(control: Control) -> void:
if TranslationServer.get_locale() in ["ar", "he", "fa"]:
var left = control.anchor_left
control.anchor_left = control.anchor_right
control.anchor_right = leftFont Fallback Chains
Handle characters not available in the primary font:
# Theme approach (recommended):
# 1. Create Theme resource
# 2. Set "FontFile" for Label/LineEdit
# 3. Add fallback fonts via DynamicFont
# Code approach:
var dynamic_font = DynamicFont.new()
dynamic_font.font_path = "res://fonts/primary.ttf"
dynamic_font.fallback_fonts.append(DynamicFontLoading.new())
$Label.add_theme_font_override("font", dynamic_font)
# For CJK + Latin support, chain fonts:
# Primary: Noto Sans (Latin) → Fallback: Noto Sans CJKTranslation Best Practices
Use Context Keys
# When the same word has different meanings:
tr("Attack [weapon]") # As a verb
tr("Attack [noun]") # As a noun/stat name
# In .po files, msgctxt provides context
# msgctxt "weapon" / msgid "Attack" / msgstr "Atacar"
# msgctxt "noun" / msgid "Attack" / msgstr "Ataque"Avoid String Concatenation for Translatable Text
# Bad — translators can't reorder
tr("You found ") + item_name + tr(" in the cave!")
# Good — translators control word order
tr("You found {0} in the cave!") % item_name
# Better — named placeholders for clarity
tr("You found {item} in {location}!") % {"item": item_name, "location": location_name}Externalize All UI Strings
# Hardcoded strings make translation impossible
$Label.text = "Score: 100" # BAD
# Use tr() for everything visible to players
$Label.text = tr("Score: {0}") % score # GOODGodot 4.7 i18n Notes
- TextServer API improved for complex script handling
- RichTextLabel supports better RTL paragraph alignment
- Translation import pipeline handles
.pofiles natively (no conversion needed)
MCP Bridge Tools (Optional — Live Editor Integration)
When the MCP bridge is running (Phase 2), these tools can inspect and modify your project live:
project_info— Check configured locales and translation file pathsscript_read/script_edit— Read and modify localization scripts
Note: MCP tools require the Godot editor to be running with the MCP plugin enabled. Skills work independently without the bridge.
References
- TranslationServer Deep Dive
- RTL Layout Patterns
- Font Fallback Strategies
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

