Dialogue Manager automatically runs all dialogue and response text through Godot’s tr() function, enabling seamless integration with Godot’s localization system. You can use either CSV files or PO (gettext) files for translations.
# In your autoload or _ready() functionDialogueManager.translation_source = DialogueManager.TranslationSource.CSV # Force CSVDialogueManager.translation_source = DialogueManager.TranslationSource.PO # Force PODialogueManager.translation_source = DialogueManager.TranslationSource.Guess # Auto-detectDialogueManager.translation_source = DialogueManager.TranslationSource.None # Disable
Setting translation source to None disables automatic translations, allowing you to handle translations manually.
Translation keys - Either the [ID:KEY] value or the dialogue text itself
Original text - The dialogue line in the default language
Translation columns - One column per language
Example CSV:
keys,en,es,frNATHAN_GREETING,"Hi! I'm Nathan.","¡Hola! Soy Nathan.","Salut ! Je m'appelle Nathan."COCO_MEOW,"Meow.","Miau.","Miaou.""What do you need?","What do you need?","¿Qué necesitas?","De quoi avez-vous besoin ?"
func _notification(what: int) -> void: if what == NOTIFICATION_TRANSLATION_CHANGED: # Update current dialogue line with new language if is_instance_valid(dialogue_label): var visible_ratio = dialogue_label.visible_ratio dialogue_line = await dialogue_resource.get_next_dialogue_line(dialogue_line.id) if visible_ratio < 1: dialogue_label.skip_typing()
## Nathan greets the player for the first timeNathan: Welcome, traveler! [ID:NATHAN_FIRST_GREETING]## Nathan is angry in this sceneNathan: Get out of here! [ID:NATHAN_ANGRY_DISMISS]
# EnglishNathan: [wave]Hello![/wave] Nice to meet you. [ID:WAVE_GREETING]# Spanish (preserving tags)Nathan: [wave]¡Hola![/wave] Encantado de conocerte.# French (preserving tags)Nathan: [wave]Bonjour ![/wave] Ravi de vous rencontrer.
Create a test locale to verify your UI handles different text lengths:
# Create a pseudo-locale for testingfunc _ready(): if OS.is_debug_build(): var pseudo = Translation.new() pseudo.locale = "pseudo" TranslationServer.add_translation(pseudo)
Nathan: You have {{player.gold}} gold coins. [ID:SHOW_GOLD]
Translators can adjust word order:
# EnglishYou have {{player.gold}} gold coins.# SpanishTienes {{player.gold}} monedas de oro.# French (different word order)Vous avez {{player.gold}} pièces d'or.
The {{player.gold}} variable is evaluated at runtime and works in all languages.