
Godot गेम लोकलाइज़ेशन की संपूर्ण गाइड
TranslationServer से लेकर फ़ॉन्ट फ़ॉलबैक तक: CSV, PO फ़ाइलों, GDScript और स्वचालित AI अनुवाद की मदद से अपने Godot गेम को लोकलाइज़ करें।
TranslationServer की बुनियादी जानकारी
Godot में पहले से शामिल TranslationServer, लोकलाइज़ेशन सिस्टम का मुख्य भाग है। यह स्टार्टअप के समय अनुवाद रिसोर्स लोड करता है और tr() फ़ंक्शन के ज़रिए कुंजियों का समाधान करता है। GDScript में tr() की प्रत्येक कॉल TranslationServer से होकर गुज़रती है—किसी अतिरिक्त लाइब्रेरी की आवश्यकता नहीं होती।
# TranslationServer is Godot's built-in localization system.
# It loads translations at startup and resolves keys via tr().
# Set the game's locale
TranslationServer.set_locale("ja")
# Get the current locale
var current = TranslationServer.get_locale() # "ja"
# Translate a key — works everywhere in GDScript
var text = tr("MENU_START") # "ゲームスタート"
# Translate with context (Godot 4.x)
var text = tr("OPEN", "verb") # "Open" (action)
var text = tr("OPEN", "adj") # "Open" (state)CSV अनुवाद फ़ाइलें
Godot में अनुवाद के लिए CSV सबसे सरल फ़ॉर्मैट है। एक फ़ाइल में सभी भाषाएँ अलग-अलग कॉलम में रहती हैं। पहला कॉलम कुंजी का होता है और उसके बाद का प्रत्येक कॉलम एक लोकेल का होता है। Godot .csv फ़ाइलों को अपने-आप इंपोर्ट करके .translation रिसोर्स जनरेट करता है।
# translations.csv
# First column = key, subsequent columns = locale codes
keys,en,ja,de,es
MENU_START,Start Game,ゲームスタート,Spiel starten,Iniciar juego
MENU_SETTINGS,Settings,設定,Einstellungen,Configuración
MENU_QUIT,Quit,終了,Beenden,Salir
ITEM_SWORD,Sword,剣,Schwert,Espada
ITEM_SHIELD,Shield,盾,Schild,Escudo
DIALOG_GREETING,"Hello, adventurer!",冒険者よ、こんにちは!,"Hallo, Abenteurer!","¡Hola, aventurero!"# In Godot Editor:
# 1. Place your .csv file in the project (e.g., res://translations.csv)
# 2. Godot auto-imports it — creates .translation resources
# 3. Go to Project > Project Settings > Localization > Translations
# 4. Add the generated .translation filesPO / Gettext अनुवाद फ़ाइलें
PO (Portable Object) फ़ाइलें सॉफ़्टवेयर लोकलाइज़ेशन का उद्योग-मानक हैं। Godot 4.x में बहुवचन, संदर्भ के आधार पर अर्थ स्पष्ट करने और अनुवादक की टिप्पणियों के लिए नेटिव PO समर्थन उपलब्ध है। locale/ डायरेक्टरी में प्रत्येक भाषा के लिए एक .po फ़ाइल बनाएँ।
# translations.po — Gettext format for Godot
# Place in res://locale/ja.po
msgid ""
msgstr ""
"Language: ja\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Plural-Forms: nplurals=1; plural=0;\n"
# Simple translation
msgid "MENU_START"
msgstr "ゲームスタート"
# Translation with context (disambiguates identical source strings)
msgctxt "verb"
msgid "OPEN"
msgstr "開く"
msgctxt "adj"
msgid "OPEN"
msgstr "開いている"
# Plural form
msgid "You collected %d coin."
msgid_plural "You collected %d coins."
msgstr[0] "%d枚のコインを集めました。"# Project Settings > Localization > Translations
# Add each .po file:
# res://locale/en.po
# res://locale/ja.po
# res://locale/de.po
# res://locale/es.po
# Or load programmatically:
func _ready():
var translation = load("res://locale/ja.po")
TranslationServer.add_translation(translation)GDScript में अनुवाद का उपयोग
स्ट्रिंग का अनुवाद करने के लिए GDScript में कहीं भी tr() का उपयोग करें। स्ट्रिंग फ़ॉर्मैटिंग के लिए इसे GDScript के % ऑपरेटर के साथ उपयोग करें। लोकेल को विश्वसनीय ढंग से प्रबंधित करने के लिए ऐसा Autoload स्क्रिप्ट बनाएँ जो सिग्नल की मदद से लोकेल का पता लगाने, उसे बनाए रखने और बदलने का काम सँभाले।
extends Control
func _ready():
# Simple key lookup
$TitleLabel.text = tr("MENU_START")
# With string formatting (positional)
$GreetingLabel.text = tr("DIALOG_GREETING_NAME") % [player_name]
# With multiple placeholders
$StatusLabel.text = tr("PLAYER_STATUS") % [player_name, level, health]
# Context-aware translation (Godot 4.x)
$ActionButton.text = tr("OPEN", "verb")
# Update UI when locale changes
TranslationServer.set_locale("de")
_update_ui()
func _update_ui():
# Re-apply all translated strings
$TitleLabel.text = tr("MENU_START")
$GreetingLabel.text = tr("DIALOG_GREETING_NAME") % [player_name]# locale_manager.gd — Register as Autoload in Project Settings
extends Node
signal locale_changed(new_locale: String)
const SUPPORTED_LOCALES = ["en", "ja", "de", "es", "fr", "ko", "zh"]
func _ready():
var system_locale = OS.get_locale_language()
if system_locale in SUPPORTED_LOCALES:
set_locale(system_locale)
else:
set_locale("en")
func set_locale(locale: String):
TranslationServer.set_locale(locale)
locale_changed.emit(locale)
func get_locale() -> String:
return TranslationServer.get_locale()बहुवचन और प्लेसहोल्डर
Godot, PO फ़ाइल के बहुवचन रूपों के ज़रिए बहुवचन सँभालता है। प्रत्येक भाषा अपने PO हेडर में स्वयं का बहुवचन फ़ॉर्मूला निर्धारित करती है। GDScript का % ऑपरेटर स्थितिगत प्लेसहोल्डर (%s स्ट्रिंग के लिए और %d पूर्णांक के लिए) सँभालता है। नाम वाले प्लेसहोल्डर के लिए String.replace() का उपयोग करें।
# Godot uses Gettext PO plural rules.
# Each language defines its own plural formula.
# English (2 forms: one, other)
msgid "You collected %d coin."
msgid_plural "You collected %d coins."
msgstr[0] "You collected %d coin."
msgstr[1] "You collected %d coins."
# Japanese (1 form: other — no singular/plural distinction)
msgid "You collected %d coin."
msgid_plural "You collected %d coins."
msgstr[0] "%d枚のコインを集めました。"
# Russian (3 forms: one, few, many)
msgid "You collected %d coin."
msgid_plural "You collected %d coins."
msgstr[0] "Вы собрали %d монету."
msgstr[1] "Вы собрали %d монеты."
msgstr[2] "Вы собрали %d монет."# GDScript string formatting with tr()
# Positional placeholders with %
var msg = tr("SCORE_MSG") % [score] # "Score: %d" → "Score: 1500"
var msg = tr("STATS") % [name, level, hp] # "%s — Lv %d — HP: %d"
# Named placeholders (manual replacement)
var template = tr("WELCOME_BACK")
var msg = template.replace("{player}", name).replace("{days}", str(days))CJK, अरबी और अन्य लिपियों के लिए फ़ॉन्ट फ़ॉलबैक
संभव है कि आपके गेम के मुख्य फ़ॉन्ट में जापानी, कोरियाई, चीनी, अरबी या थाई लिपि के ग्लिफ़ न हों। Godot 4.x फ़ॉन्ट फ़ॉलबैक शृंखलाओं का समर्थन करता है—मुख्य फ़ॉन्ट में कोई ग्लिफ़ न मिलने पर Godot क्रम से फ़ॉलबैक फ़ॉन्ट जाँचता है। इनके बिना गैर-लैटिन टेक्स्ट खाली चौकोर चिह्नों के रूप में रेंडर होता है।
# Godot 4.x supports font fallback chains.
# When a glyph is missing from the primary font, fallbacks are checked in order.
# In the Editor:
# 1. Create a LabelSettings or Theme resource
# 2. Set the primary font (e.g., Noto Sans for Latin)
# 3. Add fallback fonts: Noto Sans JP, KR, SC, Arabic
# Programmatically:
func setup_fonts():
var font = FontFile.new()
font.load_dynamic_font("res://fonts/NotoSans-Regular.ttf")
var fallback_jp = FontFile.new()
fallback_jp.load_dynamic_font("res://fonts/NotoSansJP-Regular.ttf")
font.add_fallback(fallback_jp)
$Label.add_theme_font_override("font", font)# Right-to-left (RTL) support for Arabic, Hebrew, etc.
# In the Editor:
# Select your Control node > Layout > Text Direction = RTL
# Programmatically:
func setup_rtl():
var locale = TranslationServer.get_locale()
var rtl_locales = ["ar", "he", "fa", "ur"]
if locale.substr(0, 2) in rtl_locales:
$Label.text_direction = Control.TEXT_DIRECTION_RTL
$Container.layout_direction = Control.LAYOUT_DIRECTION_RTLसीन और UI का लोकलाइज़ेशन
Godot सीन को लोकलाइज़ करने के तीन तरीके हैं: _ready() में tr() का उपयोग करके अनुवाद करें, एडिटर में Auto Translate प्रॉपर्टी का उपयोग करें या अलग लेआउट की आवश्यकता वाली भाषाओं (जैसे RTL भाषाओं) के लिए पूरी तरह अलग सीन लोड करें।
# Approach 1: Translate in _ready() using tr()
extends Control
func _ready():
$StartButton.text = tr("MENU_START")
$SettingsButton.text = tr("MENU_SETTINGS")
$QuitButton.text = tr("MENU_QUIT")
# Approach 2: Use auto-translate in the editor
# Set the Text property to the translation key (e.g., "MENU_START")
# and enable "Auto Translate" on the node.
# Approach 3: Locale-specific scenes for complex layouts
func load_localized_scene():
var locale = TranslationServer.get_locale().substr(0, 2)
var path = "res://ui/main_menu_%s.tscn" % locale
if ResourceLoader.exists(path):
add_child(load(path).instantiate())
else:
add_child(load("res://ui/main_menu_en.tscn").instantiate())LocaleChain के साथ समझदार लोकेल फ़ॉलबैक
क्षेत्रीय वैरिएंट उपलब्ध न होने पर Godot का TranslationServer सीधे प्रोजेक्ट के डिफ़ॉल्ट लोकेल का उपयोग करता है। यदि किसी pt-BR प्लेयर के लिए केवल pt-PT अनुवाद उपलब्ध हों, तो उसे पुर्तगाली के बजाय अंग्रेज़ी दिखाई देती है। LocaleChain, कॉन्फ़िगर की जा सकने वाली फ़ॉलबैक शृंखलाओं से अनुवादों को कॉन्फ़िगरेशन के समय TranslationServer में मर्ज करके इस समस्या को हल करता है।
# LocaleChain for Godot — smart locale fallback
# Install from Godot AssetLib or copy addons/locale_chain/ into your project
# Problem: Godot's TranslationServer falls back directly to the default locale.
# A pt-BR player with only pt-PT translations sees English, not Portuguese.
# Solution: One-line setup
func _ready():
LocaleChain.configure() # Uses built-in fallback chains
# Now pt-BR falls back to pt-PT → pt → default
# es-MX falls back to es-419 → es → default
# zh-Hant-HK falls back to zh-Hant-TW → zh-Hant → default
# Custom configuration:
func _ready():
# Override specific chains
LocaleChain.configure({"pt-BR": ["pt"]})
# Full custom — only your chains
LocaleChain.configure(
{"pt-BR": ["pt-PT", "pt"], "es-MX": ["es-419", "es"]},
false # don't merge defaults
)
# Reset to original state
LocaleChain.reset()गेम के अनुवाद स्वचालित करें
लोकलाइज़ेशन सेटअप पूरा होने के बाद AI की मदद से अपनी CSV या PO फ़ाइलों का अनुवाद करें। गेम की स्ट्रिंग, UI टेक्स्ट, आइटम के विवरण और संवाद का अनुवाद सीधे अपने IDE या CI/CD पाइपलाइन से स्वचालित करें।
# Translate your Godot locale files with AI
# CSV files:
# In your IDE, ask your AI assistant:
> Translate translations.csv to Japanese, Korean, and German
# PO files:
> Translate locale/en.po to ja, ko, de
# Or use the CLI in CI/CD:
npx i18n-agent translate locale/en.po --lang ja,ko,de
# The tool preserves:
# - CSV column structure and delimiters
# - PO msgctxt, msgid_plural, and plural forms
# - Placeholder syntax (%s, %d, {name})
# - Comments and metadata headersअनुवाद की गुणवत्ता स्वचालित रूप से सुनिश्चित करें
आम समस्याएँ
अनुवाद फ़ाइलें इंपोर्ट नहीं हुईं
कॉमा या उद्धरण-चिह्न वाले CSV मान पार्सिंग में समस्या पैदा करते हैं
CJK या अरबी टेक्स्ट खाली चौकोर चिह्नों के रूप में दिखाई देता है
PO हेडर में बहुवचन रूपों की संख्या गलत है
कोड ने Auto Translate को ओवरराइड कर दिया
प्रोजेक्ट की अनुशंसित संरचना
my_godot_game/
├── addons/
│ └── locale_chain/ # LocaleChain plugin (optional)
│ ├── fallback_map.gd
│ ├── locale_chain.gd
│ └── plugin.cfg
├── fonts/
│ ├── NotoSans-Regular.ttf # Primary font (Latin)
│ ├── NotoSansJP-Regular.ttf # Japanese fallback
│ ├── NotoSansKR-Regular.ttf # Korean fallback
│ └── NotoSansArabic-Regular.ttf # Arabic fallback
├── locale/
│ ├── en.po # English (source)
│ ├── ja.po # Japanese
│ ├── de.po # German
│ ├── es.po # Spanish
│ └── ar.po # Arabic
├── translations.csv # Alternative: CSV format
├── scenes/
│ └── ui/
│ ├── main_menu.tscn
│ └── settings_menu.tscn
├── scripts/
│ ├── locale_manager.gd # Autoload for locale management
│ └── ui/
│ └── main_menu.gd
├── project.godot
└── export_presets.cfgइनका भी अनुवाद करें:
i18n Agent अभी आज़माएँ
अपनी अनुवाद फ़ाइल यहाँ छोड़ें
JSON, YAML, PO, XML, CSV, Markdown, Properties
या ब्राउज़ करने के लिए क्लिक करें
लक्षित भाषाएँ
locale-chain-godot के साथ लोकेल फ़ॉलबैक
pl_PL जैसे क्षेत्रीय लोकेल में कोई अनुवाद कुंजी न मिलने पर Godot पहले उसके मूल लोकेल pl को जाँचने के बजाय सीधे प्रोजेक्ट के डिफ़ॉल्ट लोकेल का उपयोग करता है।
# Godot Asset Library से इंस्टॉल करें
# खोजें: locale-chain-godotvar lc = LocaleChain.new()
lc.configure({
"pl": ["pl_PL", "en"],
"pt_BR": ["pt", "en"],
"zh_Hant_HK": ["zh_Hant", "zh", "en"],
})समर्थित फ़्रेमवर्क और पहले से शामिल 75 शृंखलाओं की पूरी सूची के लिए हमारी लोकेल फ़ॉलबैक गाइड देखें। Learn more →