Sites


Creating Point and Click Games with Escoria

Internationalization

A point-an-click is a story and text based game, so you will probably translate your game to make it accessible to more players across the language barriers!

General game strings

General game strings are translated using the normal method for importing translations with Godot Engine, outside of Escoria. The most common way is using the "Import" menu, then "Translation" option, and use a CSV file there. Escoria provides a basic CSV file for general UI and game strings there, found in translations/general.csv (outside of the device/ directory). The translation file is exported to device/translations/general.*.xl.

Escoria i18n general.csv file example

Tooltips

All game Items have a "tooltip", a text that appears on the HUD when the mouse enters the item. This text is configured in each item, but we also need to translate it. The translation id for an item tooltip text will be the global ID of the item with the suffix ".tooltip". For convenience we also provide a setting in "Project Settings" to specify the default tooltip language (default value is "en" for English), and we also allow custom translated tooltip strings, in case you'd like to change the value of an item's tooltip, with an animation. The rules for translating a tooltip are:

  • If the current language of the game matches the language of the property "application/tooltip_lang_default", the text of the "tooltip" property is used unchanged.
  • If not, if the current text of the tooltip has a translation in the game, this translation is used.
  • Otherwise, the translation for the id [item's global id].tooltip is used. For example, if your item's id is "key", the id used is "key.tooltip", in this case you would have an entry in your translations file for "key.tooltip" with translations for all the languages. This is the most common use in combination with the default language.

Esc strings

Inside an esc file, a string can include a translation ID. The format to include an id is id:"string". For example:

say player player_speak_1:"What do you mean?"

When displaying this dialog, the game will look for the "player_speak_1" id in the loaded translations, if not found it will display the text "What do you mean?". This string format can be used anywhere where a string is found.

To translate the strings in your esc files, we provide a script that runs through all the esc files in your project, and assigns translation IDs to any string that doesn't have one. It generates a csv file with them, and also creates a new version of your esc with the translations IDs included in your strings, with the extension ".esc.lockit".

Running the script

The script can be found in tools/lockit.gd (outside of the "device" directory), and it's run using the Godot runtime, from the root of your project (the "device" directory):

godot -script ../tools/lockit.gd

After it runs, you will get a file called "strings.csv" with all the strings on your esc files, separated by file, and with some context information. You'll also have all the .esc.lockit files generated. The modifications made will look like this:

say player "this is a key"

to

say player key_look_1:"this is a key"

Assuming this is a file called "key.esc", inside the event "look", the "key_look_1" is generated.

Replacing the old esc files with the new

After running the script, you'll have a lot of ".esc.lockit" files, and you need to use these on your game. Replacing is left as an exercise to the reader :-) An example on a UNIX command line:

for f in `find . |grep esc$`; do mv $f.lockit $f; done

Remember to backup your .esc files before doing this. Double-check that the tool run correctly and that all your files are correctly generated.

Translating the strings

On the "strings.csv" file, you'll see multiple rows and columns like this:

#,"box",
##,"look",
"box_look_1","An old newspaper","player","scenes/test/box.esc:4, ", ""
"box_look_2","It's a box","player","scenes/test/box.esc:7, ", ""

The first 2 lines are separators to indicate a new file (box.esc) and a new event (look). Then you have a couple of rows with the string ID, the string content, the name of the character speaking (if it's a "say" command, otherwise the name of the command), and the path and line where the string was found. On the following columns, you can place your translated strings.

For instance in our game:

#,"bamboo_god_2",
##,"use",
...
##,"use",
"bamboo_god_2_use_2","What is the meaning of this! [i]“Made in China”?![/i]...","bamboo_god_2","scenes/second_scene/bamboo_god_2.esc:30, ", ""

TODO : is there a way to update/merge an existing translation (e.g. like gettext's msgmerge)?

Loading the translated strings

After you're done translating, you'll have a csv file with all your strings, but you can't use it directly as described in the first part of this chapter, because we have some extra rows to delimit the file and event where strings were found. Getting rid of these rows is left as exercise for the reader :-) An example on the UNIX shell:

grep -v "^#" strings.csv |grep -v "^$"|grep -v "^,*$" > strings_final.csv

This should get rid of all the lines that start with the "#" character. Remember to keep backups and make sure all you shell commands are running correctly.

After this, you should be able to import the strings_final.csv file into Godot for translations:

  • Go to the Import > Translation menu
  • Select the .csv file
  • Select a path in your game for storing compiled translations (e.g. res://translations)
  • Click Import

Godot will now generate .xl files and automatically update them when the initial .csv file is modified.

Il y a une erreur de communication avec le serveur Booktype. Nous ne savons pas actuellement où est le problème.

Vous devriez rafraîchir la page.