0 votes

Hi all,

I have followed the docs, created a UTF-8 CSV file with 3 languages.

The columns are en, es and de.
The rows have the keys named appropriately.
The labels have the text as keys that match the csv.

I imported the CSV, it found the languages, matched them.

I ran the game and voila!!! Success. All my labels changed to the en columns text. So far so good.

I then changed the language using:

TranslationServer.set_locale("es")

... but it still only shows the en columns words. Same with de, it only shows the en translation text also.

Can anyone offer any advice? It's my first ever time attempting multi languages and want to get it right from the start for testing etc.

I checked

TranslationServer.get_locale()

and it outputs the correct de or es or en.

OSX Godot 2.1.3 Stable Official.

asked Aug 16, 2017 in Engine by Robster (731 points)
edited Aug 16, 2017 by Robster

2 Answers

+2 votes
Best answer

changing locale by TranslationServer.set_locale("es") will not take effect on the fly.
you need to reload current scene or update all label on the screen.

but it is with 3.0.
https://twitter.com/reduzio/status/880125821599592448

answered Aug 16, 2017 by volzhs (7,855 points)
selected Aug 16, 2017 by Robster

Thanks so much.

I do set that as the game loads by calling a set language function in the ready area. Is that too late? If so, where can I set it so it loads into the set language on load?

Thanks again, appreciate your help.

yeap. it is too late for setting locale in _ready.
try it in _init

That did it! Multi lingual interface is away. Thanks a tonne...

0 votes

Use tr

Example:
get_node("Label").set_text(tr("Text"))

answered Aug 16, 2017 by VitaZheltyakov (209 points)
edited Aug 16, 2017 by volzhs

Thanks for your reply.

Wouldn't that mean I have to manually set every single label's text every time I change language?

I thought the idea was there was a single CSV file and depending on the KEY/TAG/ID and the language code chosen (en, de, es, fr, etc) Godot will automatically change the text depending on the language.

I'm not wanting to manually set every single label when the system is designed to do it.

Have I misinterpreted the docs?

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.