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

Fix/Update translations #810

Merged
merged 4 commits into from Jun 20, 2023
Merged

Conversation

corubba
Copy link
Contributor

@corubba corubba commented Jun 11, 2023

Fix update_translations.py

The resource must be imported so shortcuts and menues can be read.
parse_menus is unsed, they are read in parse_shortcuts too.

Update translations.py

The pylupdate5 only gathers translation keys from python sources, and not from the menu/shortcut files in data. To still make it work, update_translation.py exists to read these data files, extract their translation keys and insert them into translations.py as code. That way pylupdate5 will pick them up and properly update the .ts files.

$ ./update_translations.py de

Compile translations

The .qm file are a binary form of the .ts file, that is used during runtime.

$ lrelease translations/*.ts

Regenerate resource.py

All data files including compiled translations are not read directly from the filesystem during runtime, they are provided by the Qt
resource system. So for updated translation to actually be used, you have to regenerate the resource.py too.

$ pyrcc5 puddlestuff/resource.qrc -o puddlestuff/resource.py

The resource must be imported so shortcuts and menues can be read.
`parse_menus` is unsed, they are read in `parse_shortcuts` too.
The `pylupdate5` only gathers translation keys from python sources, and
not from the menu/shortcut files in `data`. To still make it work,
`update_translation.py` exists to read these data files, extract their
translation keys and insert them into `translations.py` as code. That
way `pylupdate5` will pick them up and properly update the `.ts` files.

$ ./update_translations.py de
The `.qm` file are a binary form of the `.ts` file, that is used during
runtime.

$ lrelease translations/*.ts
All data files including compiled translations are not read directly
from the filesystem during runtime, they are provided by the Qt
resource system. So for updated translation to actually be used, you
have to regenerate the resource.py too.

$ pyrcc5 puddlestuff/resource.qrc -o puddlestuff/resource.py
Copy link
Member

@sandrotosi sandrotosi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the change of course look good

i'm wondering about the value of keep requiring the language argument to update_translation.py -- should we just make it update all languages (in particular when changing strings in the code)?

@corubba
Copy link
Contributor Author

corubba commented Jun 19, 2023

Yeah, I know what you mean. Thought about this too, and came to the conclusion to make it optional in the future: If you don't provide it, update all languages; If you provide it, create the translation files (if needed) and update all languages (or maybe only that language). But the update_translation.py needs a bit more refactoring to achieve that, this PR is just to get it in working order and the translations into a consistent state to make the diffs on the translation files useful (and somewhat document which hoops you have to go through to actually update translations for endusers).

@sandrotosi
Copy link
Member

Yeah, I know what you mean. Thought about this too, and came to the conclusion to make it optional in the future: If you don't provide it, update all languages; If you provide it, create the translation files (if needed) and update all languages (or maybe only that language). But the update_translation.py needs a bit more refactoring to achieve that, this PR is just to get it in working order and the translations into a consistent state to make the diffs on the translation files useful (and somewhat document which hoops you have to go through to actually update translations for endusers).

cool, glad i'm not alone in seeing that as unexpected, merging this PR now

@sandrotosi sandrotosi merged commit f8b8b46 into puddletag:master Jun 20, 2023
@corubba corubba deleted the bugfix/translations branch June 20, 2023 21:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants