How can I use the translation server to translate strings on an editor plugin? It just doesn't work as expected.
On my plugin.gd, on _enter_tree()
, I do something like this
TranslationServer.add_translation(load("res://addons/myaddon/strings.pt.translation"))
print(tr("hi")) # prints "hi"
TranslationServer.set_locale("pt")
print(tr("hi")) # should print "oi" but prints "hi"
But if I create a normal scene and run the exactly same code on _ready()
, it prints exactly what's expected
TranslationServer.add_translation(load("res://addons/myaddon/strings.pt.translation"))
print(tr("hi")) # prints "hi"
TranslationServer.set_locale("pt")
print(tr("hi")) # prints "oi" exactly as expected.
Maybe it is a bug? Or is this expected behavior and I should do something different when localizing plugins?
I would like to add that those tests are made after reloading the editor one time, that is, after the csv has been properly imported by the editor and the "*.pt.translation" has been generated.