Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TranslationServer.translate() non-functional in editor #98935

Open
betalars opened this issue Nov 7, 2024 · 3 comments
Open

TranslationServer.translate() non-functional in editor #98935

betalars opened this issue Nov 7, 2024 · 3 comments

Comments

@betalars
Copy link
Contributor

betalars commented Nov 7, 2024

Tested versions

v4.3.stable.nixpkgs [77dcf97]

System information

nixos-unstable

Issue description

TranslationServer seems to not work in the editor at all, witch I partly understand, but especially it not working when being explicitly called from script is a hindrance to me right now.

Steps to reproduce

  1. check the console after opening main scene
  2. run the game

EXPECTED:
prints "Es ist Mittwoch, meine Kerle!" both times.
OBSERVED:
only prints the translated message in game.

Minimal reproduction project (MRP)

i18-editor-bug.zip

@timothyqiu
Copy link
Member

This is expected currently.

TranslationServer works, but project translations are not loaded in the editor, and translations are disabled for the edited scene.

Just curious, what's your use case for TranslationServer.translate()? If you do need to call that in some tool script, you can load your translations manually and add them via TranslationServer.add_translation().

@betalars
Copy link
Contributor Author

betalars commented Nov 8, 2024

I have a tool that dynamically stitches together a text dynamically based on translated sub-stings. I use that to gradually reveal text as it is spoken. And because the voice lines and text can have different languages, that was the most practical thing to do. Working on that tool is really annoying I must say when the translations are not available in editor.

Also: German and English have quite different lengths, so it is really difficult to work on ui when I cannot test with different translations in editor, even when I explicitly force it in code.

Also: if no locale is loaded in the editor, then
TranslationServer.get_loaded_locales()
should not return anything in editor.

I don't think your workaround works btw:

print(TranslationServer.get_loaded_locales())
TranslationServer.add_translation(preload("res://translation.de.translation"))
print(TranslationServer.translate("wensday"))

prints

["de", "en"]
wensday

@timothyqiu
Copy link
Member

I don't think your workaround works btw

Sorry, I confused the changes I'm making with the stable version / master. I am working on removing the special handling for editor translations, so that the editor's translation workflow is consistent with the game's translation workflow, so that translations can be previewed in the editor and the TranslationServer is works regularly. That could solve this issue I think (that PR still needs some work though).

For your use case, I think you can use preload("res://translation.de.translation").get_message("wesday") directly (the difference is that it returns an empty string when there is no translation for the text.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants