Localisation in Godot
Localisation is an important part of game development. If you are a small developer, it really is something to consider. Even though it is not easy and not cheap to get quality translations, sometimes it is really worth it. Localisation in Godot is easy to implement and you should always structure your game with localisation in mind.
But localisation is a double-edged sword. For example, I worked on a mobile game with the target audience in Germany and Austria, but I also translated it into Spanish. And it turned out, that that game actually was quite popular in some countries in South America. If you get bad translations on the other hand, sometimes it can be better to not translate the game at all: At some point, I did get a very poor French translation of my game. This resulted of course in bad reviews for the French version.
My advice: Go with your main language first, and if the game gets some support, then consider to translate it. But if you decide to translate it, make sure you get good quality translations.
Localisation in Godot
Localisation in Godot is not difficult. You can implement different languages very easily. But keep in mind, that if you want to support languages with different letters like Russian, you have to make sure, that the font you use supports all needed letters.
In order to use localisation in Godot you have to import your translations. For that, you should make a spreadsheet with all the languages you want to support. Make a column with id, followed by the language you want to support (have a look at the screenshot).
Below that you write your text in the desired language. Have a look here, if you don’t know a specific locale code.
Just save the file as a .csv file into your game folder (for example into a folder called translation). Godot should automatically import the files (make sure to set the delimiter to “comma when saving to .csv format” and check, if the Import settings are also set to comma).
For every language, Godot should create a separate file with a .translation ending (check out the screenshot). Once the file is imported, you can change that file however you like. Just always save it as .csv and Godot will import all the changes.
Then go to Project Settings and add all relevant translation files:
How to use Localisation in Godot
In order to use the text in your spreadsheet you can call
to get the wanted line of text. If you have a Label with the name myText for example, you can call
Godot will then check the id string_day in your spreadsheet and returns the right string.
Insert values into your texts
You can also use the usual format strings. So if you like to insert a value into your translated text, make sure to add %s to the text in your spreadsheet.
Then you can assign a value like this:
myText.set_text(tr("string_w_value") % str(3)))
In this example, your label would show “I have 3 cats!”. Here you can find more info on format strings in GDScript, if you like to learn more.
Another way is to just type in the text id into the Node field itself. So if you have a key that is called options_f, you can just type that id into the text field of the Label. It then searches the right line of text in your spreadsheet.
Change the language
To change the current language in runtime you can use the TranslationServer. For example to use the German translation you can write the following into your _ready() function:
func _ready(): TranslationServer.set_locale("de")
As you can see, localisation in Godot is useful and not to hard to implement. For more information or other interesting topics check out the following links:
To learn more about the Godot Engine I can recommend Godot Engine Game Development Projects by Chris Bradfield. If you are interested, you can follow the affiliate link to also support this website.