check if translation ID exists

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

is there a way to check if a certain translation exists?"SOME_ID")

returns the right string according to the language set in TranslationServer.set_locale(en).

But how can I verify if “SOME_ID” even exists?


:bust_in_silhouette: Reply From: Bojidar Marinov

Looking at the class reference, Translation::get_message_list seems to do the job, and you can load Translation as a resource with load/preload. E.g:

if "SOME_ID" in preload("res://translations/en.tres").get_message_list():

it worked, thanks.

Although I had to import the translation as a resource and deactivate the “compress” option. Otherwise I was not able to access the translation.

twinpixel | 2016-04-07 13:36

:bust_in_silhouette: Reply From: BlotoPK

Also you can do:if tr("SOME_ID") != "SOME_ID":.