dolphin icon indicating copy to clipboard operation
dolphin copied to clipboard

Android Translation Scripts

Open t895 opened this issue 2 years ago • 7 comments

Learned some python and put together a couple of scripts that will now allow Android to get translations from Transifex. I think I'm formatting everything correctly but @JosJuice probably knows best.

This doesn't include the results from the scripts, but I could run them and commit the results here if needed. We already get a good few partial Android translations.

Note about the python scripts, they require lxml and polib to run.

t895 avatar Feb 27 '23 04:02 t895

The handling of newlines is kind of funky. These two strings should ideally be equivalently identical in the .pot files (to save translators from having to deal with them twice):

https://github.com/dolphin-emu/dolphin/blob/74abf482347e3073d2115a10ff72019567d03f3c/Source/Core/DolphinQt/ConvertDialog.cpp#L87-L96

https://github.com/dolphin-emu/dolphin/blob/2c24d07837b9ab94219de592adf34a35a2dc897e/Source/Android/app/src/main/res/values/strings.xml#L590-L598

The DolphinQt string currently looks like this:

#: Source/Core/DolphinQt/ConvertDialog.cpp:87
msgid ""
"ISO: A simple and robust format which is supported by many programs. It "
"takes up more space than any other format.\n"
"\n"
"GCZ: A basic compressed format which is compatible with most versions of "
"Dolphin and some other programs. It can't efficiently compress junk data "
"(unless removed) or encrypted Wii data.\n"
"\n"
"WIA: An advanced compressed format which is compatible with Dolphin "
"5.0-12188 and later, and a few other programs. It can efficiently compress "
"encrypted Wii data, but not junk data (unless removed).\n"
"\n"
"RVZ: An advanced compressed format which is compatible with Dolphin "
"5.0-12188 and later. It can efficiently compress both junk data and "
"encrypted Wii data."
msgstr ""

The Android string currently looks like this:

msgid ""
"\n"
"ISO: A simple and robust format which is supported by many programs. It "
"takes up more space\n"
"than any other format.\n"
"\\n\\nGCZ: A basic compressed format which is compatible with most versions "
"of Dolphin and some\n"
"other programs. It can\\'t efficiently compress junk data (unless removed) "
"or encrypted Wii data.\n"
"\\n\\nWIA: An advanced compressed format which is compatible with Dolphin "
"5.0-12188 and later,\n"
"and a few other programs. It can efficiently compress encrypted Wii data, "
"but not junk data\n"
"(unless removed).\n"
"\\n\\nRVZ: An advanced compressed format which is compatible with Dolphin "
"5.0-12188 and later.\n"
"It can efficiently compress both junk data and encrypted Wii data.\n"
"    "
msgstr ""

JosJuice avatar Feb 27 '23 19:02 JosJuice

Just wondering...does this have to be in the same translation file? Does transifex support the Java XML natively perhaps?

BhaaLseN avatar Feb 28 '23 17:02 BhaaLseN

Just wondering...does this have to be in the same translation file? Does transifex support the Java XML natively perhaps?

To avoid duplicates in the upload we currently do, yes. But I'm not sure if they have a supported way of merging it on their end and extracting it back out into the correct directories for Android. I'm contacting their support now to be sure.

t895 avatar Feb 28 '23 17:02 t895

To avoid duplicates in the upload we currently do, yes.

Oh, I guess I missed the part where we reuse strings across Qt and Android. In that case, it kinda makes sense.

You might want to look into Translate toolkit. We use Weblate at work (not Transifex), and it supports a wide range of formats (plus also conversion between them and .po/.pot). YMMV tho, since the strings.xml format is super simple and you might not wanna bring a big library like that in just to read/write a file.

BhaaLseN avatar Feb 28 '23 17:02 BhaaLseN

You might want to look into Translate toolkit. We use Weblate at work (not Transifex), and it supports a wide range of formats (plus also conversion between them and .po/.pot). YMMV tho, since the strings.xml format is super simple and you might not wanna bring a big library like that in just to read/write a file.

Ooh, if Transifex doesn't have a supported way of merging, this looks like a better way of parsing strings.xml. I really appreciate the advice!

t895 avatar Feb 28 '23 17:02 t895

Just for the record, I checked with Transifex and they have no way of merging translations on their end besides using a "Translation Memory" feature that would require having a paid enterprise account. This is obviously infeasible and I'll just continue with these scripts.

t895 avatar Mar 02 '23 06:03 t895

Needs a rebase

lioncash avatar Nov 30 '23 04:11 lioncash