Translation not working (from english, to german, to spanish, etc)

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Robster
:warning: Old Version Published before Godot 3 was released.

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.

:bust_in_silhouette: Reply From: VitaZheltyakov

Use tr

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

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?

Robster | 2017-08-16 11:21

:bust_in_silhouette: Reply From: volzhs

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

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.

Robster | 2017-08-16 12:19

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

volzhs | 2017-08-16 12:21

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

Robster | 2017-08-16 12:33