+1 vote

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.

in Engine by (835 points)
edited by

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

by (9,782 points)
selected by

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"))

by (208 points)
edited by

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 Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.