Closed probonopd closed 3 years ago
Running pylupdate5 . -ts i18n/en.ts
creates a file that Weblate can use to translate strings.
Questions:
pylupdate5
- do we need to use that one instead (from FreeBSD package py37-qt5-xml
)? It doesn't seem to scan the whole directory tree at once but seems to require a .pro
file which makes everything even more complex than needed?.app
bundle for each application? (If we go with one ts file and hence one Weblate subproject per application, then maybe we don't even need to do this work...).ts
files in the .app
bundles (which makes it easier to work on the translations while using the application) or do we need to compile them down to binary .qm
files?* Do we need a separate ts file, and hence a separate Weblate subproject for each of the utilities? * How is Hosted Weblate supposed to get its permissions to push something into a GitHub Repository? Doesn't one need to enter a GitHub Token somewhere into the Weblate GUI? (Where is this documented?) * Alternatively, how exactly does one need to set up hosted Weblate so that it creates (and appends to existing) GitHub Pull Requests instead of trying to push?
Pending on
* Approval from Weblate as a free hosted open source project * [WeblateOrg/weblate#3533 (comment)](https://github.com/WeblateOrg/weblate/issues/3533#issuecomment-778759649)
Have a look at https://docs.weblate.org/en/latest/vcs.html You have to add the weblate User to the Git repo. So you can grant weblate access. For Upload it looks like a SSH Key is required.
Addded the user weblate
as a collaborator with read access on GitHub. In the hope that this will allow it to make pull requests.
It is still not making pull requests. What exactly do I need to configure in https://hosted.weblate.org/settings/hellosystem/utilities/#vcs so that it makes pull requests?
Now setting git@github.com:helloSystem/Utilities.git
as the Push URL in Weblate and giving the Weblate user Write rights in https://github.com/helloSystem/Utilities/settings/access...
This seems to have done the trick, no SSH keys neded.
But I would prefer the bot not to push but use Pull Requests...
Yea absolutly. I don't know if it's even a good idea, to have this fully automated. Do we have controll who has access to the weblate instance?
I think that only the Weblate admin for the project (that would be me) can trigger a push. In any case, the good thing about GitHub pushes is that they can be reverted if something goes wrong.
Ok, this sounds good. Normally this translation scripts really works well. they don't destroy code. Well, I don't have experiance with this particular one, but with the one i worked, it worked really well.
I am still looking for the leanest way to translate PyQt5 applications, ideally without the need to compile anything. After all, I chose PyQt5 specifically because it doesn’t need to be compiled…
Am I missing something?
https://forum.learnpyqt.com/t/impossible-translations/298/9
Not so easy: https://simpleit.rocks/python/how-to-translate-a-python-project-with-gettext-the-easy-way/
Those extra steps for compiling are really bothering me. After all, git is not great in storing compiled blobs, and we don't want to need a compile pipeline for PyQt stuff (or else we could have gone with a compiled language right from the start)
Possibly we need to define a custom _
function that uses something like https://github.com/alexshpilkin/po/blob/master/po.py to extract the translation directly from a po file?
We can't be the first ones to run into this...?
I have a proof-of-concept working for a system that uses raw Qt .ts
files to translate the UI without the need for compilation:
This requires the Python module translate-toolkit
to be installed with sudo python3 -m pip install translate-toolkit
as it apparently is not available in FreeBSD packages.
The proof-of-concept currently uses .ts
files from outside of the appliction bundle because we have all translations for all applications in entire repository in the same set of .ts
files.
We probably need to split this up and have one .ts
file for each application.
Is this possible to set up easily in Hosted Weblate without having to create one Weblate project per application in this repository?
To generate/update the English .ts
file, use something along those lines?
FreeBSD% mkdir -p Preferences/Users.app/Resources/i18n
FreeBSD% pylupdate5 -verbose -noobsolete Preferences/Users.app/Resources/*{py,ui} -ts Preferences/Users.app/Resources/i18n/en.ts
Updating 'Preferences/Users.app/Resources/i18n/en.ts'...
Found 11 source texts (11 new and 0 already existing)
Unlike lupdate
which seemingly cannot use .py
files as the input, pylupdate5
one can, but it cannot work on a whole directory recursively. And unfortunately it produces bigger output files because it inserts lines like <location filename="../Preferences/Users.app/Resources/adduser.py" line="21"/>
. I wonder whether we could change it to better suit our needs (it's Python, after all).
In the meantime we can use
sudo pkg install -y xmlstarlet
FreeBSD% xml ed -L -d '//location' Preferences/Users.app/Resources/i18n/en.ts
to remove the unwanted <location/>
tags.
Is this possible to set up easily in Hosted Weblate without having to create one Weblate project per application in this repository?
This looks exactly like what we need:
https://docs.weblate.org/en/latest/admin/addons.html#component-discovery
Automatically adds or removes project components based on file changes in the version control system.
Triggered each time the VCS is updated, and otherwise similar to the import_project management command. This way you can track multiple translation components within one VCS.
Unfortunately Murphy's Law is hitting me: Not having looked at Hosted Weblate for half a year, it is now down for 600 minutes exactly when I wanted to have a look at it again. Not complaining, just saying.
As we can see in
we have
Utilities/Developer Preview/Format Disk.app/Resources/i18n/formatdisk_en.ts
Utilities/Developer Preview/Format Disk.app/Resources/i18n/formatdisk_de.ts
I would like to set up Weblate to find these but I can't get it to work:
Like this it works but then the component
variable becomes Developer Preview/Format Disk.app/Resources/i18n/formatdisk
rather than formatdisk
or Format Disk.app
:
How to solve this?
In the meantime, I can add the individual applications one-by-one by hand lke this:
https://hosted.weblate.org/projects/hellosystem/ -> Add new translation component -> From existing component -> Under "Component name" enter the name of the application (without ".app") (e.g., "Format Disk") -> Under "Component" select "helloSystem/Utilities" -> Continue -> Select the appropriate directory where the translations reside -> "Do NOT enter anything in "Monolingual base language file".
Works but is manual work for each application.
Basic setup is working now and documented at https://hellosystem.github.io/docs/developer/localization.
@louies0623 I see you contributed translations for many Asian languages. Thank you very much, highly appreciated. Do you actually speak all of those languages? Hats off. May I add you to https://hellosystem.github.io/docs/developer/acknowledgements?
weblate
in https://github.com/helloSystem/Utilities/settings/access and give it Write rightsPending on