Übersetzung von Spielen

Einführung

Sería excelente que el mundo hablara solo un idioma (Es wäre gut wenn die Welt nur eine Sprache sprechen würde). Zum Leidwesen für uns Entwickler ist dem nicht so. Kleine Indie oder Nischen Spiele benötigen keine Lokalisierung, größere Spiele die auf den breiten Massenmarkt zielen benötigen dies aber auf jeden Fall. Godot bietet viele Tools, um diesen Prozess einfacher zu gestalten. Daher ähnelt diese Anleitung eher einer Sammlung von Tipps und Tricks.

Die Lokalisierung wird in der Regel von speziellen Studios durchgeführt, die für diese Aufgabe angeheuert werden, und trotz der riesigen Menge an Software und Dateiformaten, die dafür zur Verfügung stehen, ist die gängigste Art, die Lokalisierung durchzuführen, bis heute immer noch mit Tabellenkalkulationen. Der Prozess des Erstellens der Tabellenkalkulationen und des Importierens wird bereits im Übersetzungen importieren-Tutorial behandelt, so dass dieses Tutorial eher als eine Fortsetzung dieses Tutorials gesehen werden kann.

Bemerkung

Wir werden die offizielle Demo als Beispiel verwenden. Sie können es aus der Bestandsbibliothek herunterladen.

Konfigurieren der importierten Übersetzung

Übersetzungen können aktualisiert und neu importiert werden, wenn sie sich ändern, aber sie müssen noch zum Projekt hinzugefügt werden. Dies geschieht in Projekt → Projekteinstellungen → Lokalisierung:

../../_images/localization_dialog.png

Der obige Dialog wird verwendet, um Übersetzungen projektweit hinzuzufügen oder zu entfernen.

Ressourcen lokalisieren

Es ist auch möglich, Godot anzuweisen, abhängig von der aktuellen Sprache alternative Versionen von Assets (Ressourcen) zu verwenden. Dazu kann die Registerkarte Remaps verwendet werden:

../../_images/localization_remaps.png

Wählen Sie die Ressource aus, die neu zugeordnet werden soll und fügen Sie dann für jedes Gebietsschema einige Alternativen hinzu.

Schlüssel in Text konvertieren

Some controls, such as Button and Label, will automatically fetch a translation if their text matches a translation key. For example, if a label's text is "MAIN_SCREEN_GREETING1" and that key exists in the current translation, then the text will automatically be translated.

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)

In code, the Object.tr() function can be used. This will just look up the text in the translations and convert it if found:

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

In der Größe veränderbare Steuerelementen erzeugen

The same text in different languages can vary greatly in length. For this, make sure to read the tutorial on Größe und Bezugspunkte (Anker), as dynamically adjusting control sizes may help. Container can be useful, as well as the text wrapping options available in Label.

Übersetzungsserver

Godot has a server handling low-level translation management called the TranslationServer. Translations can be added or removed during run-time; the current language can also be changed at run-time.

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.

Die Übersetzung kann getestet werden, wenn Godot über die Befehlszeile ausgeführt wird. Um beispielsweise ein Spiel auf Französisch zu testen, kann das folgende Argument angegeben werden:

godot --language fr

Übersetzen des Projektnamens

The project name becomes the app name when exporting to different operating systems and platforms. To specify the project name in more than one language, create a new setting application/name in the Project Settings and append the locale identifier to it. For instance, for Spanish, this would be application/name_es:

../../_images/localized_name.png

If you are unsure about the language code to use, refer to the list of locale codes.