Skip to content

Internationalization and story localization

The KND_I18n autoload manages Godot UI translations, the language setting, localized .ks files, and live story reloads. The current locale is stored in display/language.

Built-in locale codes are zh_Hans, zh_Hant, en, ja, and ko. Legacy values such as zh-CN, tc, and zh-TW are normalized automatically.

Changing the locale

Use the settings service in normal application code:

gdscript
KND_Settings.set_setting("display", "language", "ja")

Or call the internationalization service directly:

gdscript
KND_I18n.set_locale("ja")
KND_I18n.locale_changed.connect(func(locale: String): print(locale))

set_locale() updates TranslationServer, persists the setting, and asks registered dialogue managers to reload their story.

Localized story files

For res://dialogues/chapter.ks, add variants beside the base file:

text
res://dialogues/chapter.zh_Hant.ks
res://dialogues/chapter.en.ks
res://dialogues/chapter.ja.ks

Resolution order is the complete locale (pt_BR), the base language (pt), then the original .ks file. During a locale change Konado restores the stable node_id when possible, then the matching index, and finally the target story's start node.

Custom UI translations

gdscript
var translation := Translation.new()
translation.locale = "fr_CA"
translation.add_message("开始游戏", "Commencer")
KND_I18n.register_translation(translation)
KND_I18n.set_locale("fr_CA")

Use unregister_translation("fr_CA") to remove it. get_available_locales() includes built-in and custom locales.

Loading a localized story manually

gdscript
var shot: KND_Shot = KND_I18n.load_localized_script(
	"res://dialogues/chapter.ks",
	"en"
)

The method returns null with a clear error when loading fails.

Released under BSD3-Clause License.