system
1
|
|
|
 |
Attention |
Topic was automatically imported from the old Question2Answer platform. |
 |
Asked By |
twinpixel |
 |
Old Version |
Published before Godot 3 was released. |
is there a way to check if a certain translation exists?
Object.tr("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?
Thanks.
system
4
|
|
|
 |
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
system
5
|
|
|
 |
Reply From: |
BlotoPK |
Also you can do:if tr("SOME_ID") != "SOME_ID":
.