Hi i’m Iki.
Do you want a multilanguage system on your video game?
I want my videogame to be played in English and Spanish.
So first i need a text element where i’m going to display the text that i’m going to translate.
In my case i choose a label.
Here i’ll show a welcome message for the example, but you can create menu buttons or whatever you want.
The translations will be saved on a local database, in a CSV file. This is a sheet file, like Excel.
There’s a free software to create and edit this files, so let’s download LibreOffice.
Once installed, i create a new sheet document.
Now i need to place all my texts here. You could have all your dialogs in just this one document.
I am going to use one column for the English language, and another for Spanish, but if you have more languages you can use more columns.
For Godot to identify that it is the English language, I must place the word en_US, and for it to identify Spanish, I must place es_ES. I’ll show you this later, but I’ll put the Spanish wrong so you can see what would happen.
Note that I reserved a first column, and here I am going to enter a name to identify each text that I am going to use. As I can have many texts to translate, I have to assign them a name.
So each row will hold a different text.
Once finished, I save the file as CSV format.
We have other encoding options, which will depend a bit on the language we are using. By default it usually has the appropriate configuration.
I get an error, and it’s because I put the name wrong in Spanish.
Just in case, it is good to reimport any error, and also check that the tabulation of the elements is correctly specified according to the configuration of your document.
Now it only remains to use the values of the document. I’m going to assign one of them to my label.
But first I have to tell Godot where my translations file is, from the translations menu.
Then I select the corresponding languages from the list. Here you can see the value that would correspond to it in the document.
Finally, we link in our code, using the TR function, and indicating the name of the value to take. Notice that I use the values from the previously created document.