ゲームの国際化

はじめに

Sería excelente que el mundo hablara solo un idioma(世界が一つの言語しか話さなかったら素晴らしいことだ)。残念ながら、私たち開発者にとっては、そうではありません。インディーズのゲームやニッチなゲームは通常ローカライズを必要としませんが、より大規模な市場をターゲットにしたゲームは、多くの場合、ローカライズを必要とします。Godot は、このプロセスをより簡単にするための多くのツールを提供しています。このチュートリアルは、ヒントとコツを集めたようなものです。

ローカライズは通常、仕事のために雇われた特定のスタジオによって行われ、このために利用可能なソフトウェアとファイル形式の膨大な量にもかかわらず、今日にローカライズを行う最も一般的な方法は、まだスプレッドシートです。スプレッドシートの作成とインポートのプロセスについては、翻訳のインポートチュートリアルですでに説明されています。

注釈

公式デモを例に使用します。アセットライブラリからダウンロードできます。download it from the Asset Library

インポートされた翻訳の構成

翻訳は変更時に更新および再インポートできますが、プロジェクトに追加する必要があります。これは プロジェクト → プロジェクト設定 → ローカライズ で行います:

../../_images/localization_dialog.png

上記のダイアログは、プロジェクト全体の翻訳を追加または削除するために使用されます。

リソースのローカライズ

また、現在の言語に応じて、アセット(リソース)の代替バージョンを使用するようにGodotに指示することもできます。Remapsタブは、次の場合に使用できます:

../../_images/localization_remaps.png

リマップするリソースを選択し、ロケールごとに代替手段を追加します。

キーをテキストに変換する

ButtonLabelなどの一部のコントロールは、テキストが翻訳キーと一致する場合に自動的に翻訳を取得します。たとえば、ラベルのテキストが「MAIN_SCREEN_GREETING1」で、そのキーが現在の翻訳に存在する場合、テキストは自動的に翻訳されます。

This automatic translation behavior may be undesirable in certain cases. For instance, when using a Label to display a player's name, you most likely don't want the player's name to be translated if it matches a translation key. To disable automatic translation on a specific node, use Object.set_message_translation and send a Object.notification to update the translation:

func _ready():
    # This assumes you have a node called "Label" as a child of the node
    # that has the script attached.
    var label = get_node("Label")
    label.set_message_translation(false)
    label.notification(NOTIFICATION_TRANSLATION_CHANGED)

For more complex UI nodes such as OptionButtons, you may have to use this instead:

func _ready():
    var option_button = get_node("OptionButton")
    option_button.set_message_translation(false)
    option_button.notification(NOTIFICATION_TRANSLATION_CHANGED)
    option_button.get_popup().set_message_translation(false)
    option_button.get_popup().notification(NOTIFICATION_TRANSLATION_CHANGED)

コードでは、Object.tr() 関数を使用できます。これにより、翻訳のテキストが検索され、見つかった場合は変換されます:

level.set_text(tr("LEVEL_5_NAME"))
status.set_text(tr("GAME_STATUS_" + str(status_index)))

コントロールのサイズを変更可能にする

異なる言語で同じテキストの長さが大きく異なる場合があります。このためには、コントロール サイズを動的に調整すると役立つ可能性があるため、サイズとアンカー のチュートリアルを必ずお読みください。Container だけでなく、Label で使用できるテキストの折り返しオプションも便利です。

翻訳サーバー

Godot には、TranslationServer と呼ばれる低レベルの翻訳管理を処理するサーバーがあります。翻訳は、実行時に追加または削除できます。現在の言語は、実行時に変更することもできます。

Testing translations

You may want to test a project's translation before releasing it. Godot provides two ways to do this.

First, in the Project Settings, under Input Devices > Locale, there is a Test property. Set this property to the locale code of the language you want to test. Godot will run the project with that locale when the project is run (either from the editor or when exported).

../../_images/locale_test.png

Keep in mind that since this is a project setting, it will show up in version control when it is set to a non-empty value. Therefore, it should be set back to an empty value before committing changes to version control.

Translations can also be tested when running Godot from the command line. For example, to test a game in French, the following argument can be supplied:

godot --language fr

プロジェクト名の翻訳

異なるオペレーティングシステムやプラットフォームにエクスポートするときに、プロジェクト名がアプリ名になります。複数の言語でプロジェクト名を指定するには、プロジェクト設定 で新しい設定 application/name を作成し、ロケール識別子を追加します。たとえば、スペイン語の場合、これは application/name_es になります:

../../_images/localized_name.png

使用する言語コードが不明な場合は、list of locale codes を参照して下さい。