Open anisc opened 3 years ago
As I said before, I haven't used it yet, but upon inspecting the docs, it seems like it should work like a normal label. Have you tried? What didn't work here, but did with a normal Godot label?
It work as a normal label
Because the whole reshaping happen at the .arabic_input level and because the translation key will be entered there too(arabic_input) the translation will happen at the .text level so will not be reshaped and will behave the same as Label.
So what I'm doing is, On _ready I force the translation in the .arabic_input
$Label.arabic_input = translationserver.translation(""string")
This is a workaround, not a fix. At least not yet. Can you share/link a minimal project which uses the translation server? I couldn't find any, nor figure out how to use it.
https://github.com/anisc/godotArabicPluginTest The way the translation server works: you create a file.csv with a special format ( I use google sheet ):
Key | language1 | language2 |
---|---|---|
key1 | word1 in language1 | word1 in language1 |
key2 | word2 in language1 | word2 in language1 |
on godot Project>Project Settings >Localization
click on add and navigate to where ever you did place your file.csv, you will find file.language1.translation and file.language2.translation just load those. and you just have to enter the key on the text of the label, Godot will do the rest.
On the example I made you can change the language by clicking on the button ( change language) .
I see where the problem is, now.
Godot automagically overwrites the text
property of text-bearing objects while translating; this is constantly being overwritten by the properly rendered output of arabic-input
.
Ideally, it'd be best to have it just work with Godot, rather than monkey patch a solution.
Thus, it'll be one of two:
1) Redesign the label code so text
is both the input and the output, and that it is processed by BIDI code only once for every change in text.
2) Or, failing that, monkey patch.
You are the expert :) thank you for sharing the plugin tho really appreciated ! and it seems that Godot are working on something to support arabic with godot 4 requiring to rethink their approach: https://godotengine.org/article/complex-text-layouts-progress-report-1 https://godotengine.org/article/complex-text-layouts-progress-report-2 https://godotengine.org/article/complex-text-layouts-progress-report-3
Yep, I'm aware. I plan to deprecate this when godot 4 comes out.
Progress report: I tried, brain broke. Might monkey patch instead.
The problem is that with the way godot translation works, it's transparent to the attached script: text
, in this case, the translation key, never changes, only what is displayed does. This script works by replacing disconnected glyphs with connected ones, writing to text
. You can see how they're at odds.
I tried something like this:
func set_text(s):
var translated = TranslationServer.translate(s)
if translated!=s:
if TranslationServer.get_locale() == "ar":
var temptext = wrap_text(s) if autowrap else s
translated = arabic.process_text(temptext)
.set_text(translated)
#_set_arabic_input(s)
but didn't work. I think for now the workaround would be good enough, as this plugin will be deprecated any way.
Is there any way to use this plugin to work with the translation server ?