Hi, I'm Hideki.
This article is originally posted here.
I use Godot when developing my games in most cases.
By the way, I am Japanese.
So I make my game in Japanese first. But I want people all over the world to play my game so I need to make it internationalized.
Godot is great. We can do it easily😍
1. Make CSV files
As written in this document, We need to make .csv
files that describes the translation of each words.
For example:
keys, en, ja
INFO,About this game,このゲームについて
SAVED,"Saved successfully.","保存しました。"
RESET,"Reset successfully.","リセットしました。"
keys(here INFO, SAVED, RESET)
will be used in your code in gdscript later.
Separate each word with a comma(,) for each language.
2. Import .csv file
Now, put this .csv file into the root of your Godot project.
For example:
Click this .csv file and click the Import
tab.
Click "Reimport".
3. Configure the translations.
Go to Project
-> Project Settings
and then click Localization
tab.
You can add the translation file(ex: text.en.translation
) by pressing the Add...
button.
4. Convert key to text
When you created .csv
file, you specified some keys(In my situation, INFO, SAVED, etc...). The opportunity to use it has come.
For instance:
$Label.text = "SAVED"
If you write like the above, the string "SAVED" is converted to "保存しました。" in the devices supported Japanese, or "Saved successfully." in the other devices.
Well done!
5. Test
If you want to check if localization works properly, you can check it by the following:
func _ready():
TranslationServer.set_locale("en")
*"en" is the language you want to check.
Please refer to the Locale list to check the language code you want.
Top comments (0)