generated at
Godot: Localization(i18n)
基本は、CSVファイルを用意してインポートする
key となる列と、各言語文字列の列を埋めたCSV

Project Settings で、Localization の設定を Add する
現在設定されている言語に応じて文字列を表示したい箇所で、 Object.tr() 関数を呼び出す
gd
level.set_text(tr("LEVEL_5_NAME"))

ゲーム中に動的に言語を切り替えたい場合
OptionButtonを設置し、Items に各言語要素を設定する
optionButton の item_selected signal を受け取り、TranslationServer.set_localで言語を切り替える
gd
func _on_language_selector_item_selected(index: int) -> void: match index: 0: TranslationServer.set_locale("ja") 1: TranslationServer.set_locale("en") _: TranslationServer.set_locale("en")


こちらの記事も参考になる
プレイヤー名を表示する場所などで自動翻訳機能を無効にしたい時
>While Godot can translate automatically for you, saving you time and resources for actual game development, this may be problematic in some cases. For example, if you do not want to translate a player's name that matches one of your translation keys, you can disable the auto-translation feature by using the following script:
gd
func _ready(): # assuming that the script node contains a Label node called NameLabel var label = get_node("NameLabel") label.set_message_translation(false) label.notification(NOTIFICATION_TRANSLATION_CHANGED)
Formatting strings
動的に数値や文字列を埋め込める
CSVの文字列内に % placeholder を埋め込んでおき
csv
... POINTS,You gained %d point,Ganaste %d punto,%dポイントを得た
表示箇所で format string を使う
gd
var count = 5 var msg = tr("POINTS") % [count] # You have gained 5 points!
Formatting dates
国ごとに日付情報を表示する方法も紹介されている