Skip to content

Conversation

@nilsding
Copy link
Member

@nilsding nilsding commented May 6, 2025

-a / --all does not include the source language apparently.

This is required to make plural forms (e.g. 1 file, 5 files) work correctly when using the en translation.

`-a` / `--all` does not include the source language apparently.

This is required to make plural forms (e.g. *1 file*, *5 files*) work
correctly when using the `en` translation.

Signed-off-by: Jyrki Gadinger <[email protected]>
@nilsding nilsding requested a review from mgallien May 6, 2025 08:13
@nilsding nilsding self-assigned this May 6, 2025
@rakekniven
Copy link
Member

Just some notes from my side:
"en" is the source language and Transifex does not offer a translation for it. Instead it offers to modify strings of source language.
I am not sure what happens if I change strings of "en" at Transifex.

@nilsding You added comment "required for plural forms to work". They will work for every translation language.
So we have "en_GB" and this should be language for english, or?
The server uses american english IIRC for the source strings.

@nilsding
Copy link
Member Author

nilsding commented May 8, 2025

@rakekniven The main concern I have about the plural forms is that these are provided through the translation files. en (US, the base language all translatable strings in our codebase) and en_GB are two different translations.

I'm not sure what would happen when the base strings are changed from within Transifex myself either. To me it seems like it's at least possible to adapt the plural forms there as well -- at least when I pulled the source file from Transifex I saw a few newer ones in there.

Another possible solution for that topic could be that we'll update the client_en.ts translation ourselves whenever we introduce/change strings containing plurals.

@rakekniven
Copy link
Member

rakekniven commented May 8, 2025

I don't quite understand your thoughts on the plural forms.
What is the difference for you between a string with and without plural forms?

Or is your point that the plural forms are also correct for "en"?

Another possible solution for that topic could be that we'll update the client_en.ts translation ourselves whenever we introduce/change strings containing plurals.

Wuh, I doubt this will work in real life. Maybe I am wrong.

@nilsding
Copy link
Member Author

nilsding commented May 8, 2025

For strings to be translatable, we use Qt's tr function (e.g. tr("hello, world")).
Since the rules of plural forms are different in many languages*, we need to pass a number to that function for the correct form to appear (e.g. tr("%n minute(s) remaining", "", 1)).

The different plural forms are part of the translation files -- in the .ts files these can be found by looking for <message numerus="yes"> and <numerusform>.
When a string does not appear in the specific translation (it might not have been translated yet after all), the untranslated string from the source code will be displayed instead. This is usually fine for all the cases where we don't need to account for the plurals, but it's not nice for the ones where we do (e.g. a string would now show up as 1 minute(s) remaining in the UI, instead of 1 minute or 2 minutes).

I doubt this will work in real life. Maybe I am wrong.

well, there's only one way to find out ;-)
We can add a new check to each PR that reminds ourselves to taking care of these strings if we changed them.


* The Qt docs have a list of these rules, each of those is used by more than just the language mentioned: https://doc.qt.io/qt-6/i18n-plural-rules.html
That table makes it clear that manually handling the plural forms (e.g. myString = (count == 1) ? tr("1 minute") : tr("%1 minutes").arg(count);) won't work for all languages...

@nilsding
Copy link
Member Author

Closing this one in favour of #770 -- we should update the source file through that script in the repo, but that got broken at some point.

@nilsding nilsding closed this May 20, 2025
@nilsding nilsding deleted the feature/desktop-pull-source-translations branch May 27, 2025 12:03
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.

3 participants