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

Plural forms in Slovenian and other languages #1488

Closed
buhtz opened this issue Jul 28, 2023 · 4 comments · Fixed by #1490
Closed

Plural forms in Slovenian and other languages #1488

buhtz opened this issue Jul 28, 2023 · 4 comments · Fixed by #1490
Assignees
Milestone

Comments

@buhtz
Copy link
Member

buhtz commented Jul 28, 2023

@b100w11 reported at #1465.

There are some issues with the slovenian translation (and i guess also with others).
Slovenian has different plural forms based on the last number of the plural (this is probably an oversimplification and the linguists will have something to complain, but it explains the issue).
So if we take an example with "knjiga" (book) we have this forms.

1 knjiga
2 knjigi
3-4 knjige
5 knjig

The same pattern repeats with "101 knjiga", "102 knjigi", ... , "1001 knjiga", "1002 knjigi" and so on.

The gettext solution is this
"Plural-Forms: nplurals=4; plural=(n%100==1 ? 1 : n%100==2 ? 2 : n%100==3 || n%100==4 ? 3 : 0)\n"

So it should work for every instance where there is a singular and plural form.
Something similar should also solve the "day(s)" problem in English and other languages.
I don't know where to incorporate this.

@buhtz buhtz added this to the upcoming release (1.3.4) milestone Jul 28, 2023
@buhtz buhtz self-assigned this Jul 28, 2023
@buhtz
Copy link
Member Author

buhtz commented Jul 28, 2023

Thanks for reporting this. I'm not well experienced with that plural forms feature. But this is a good oportunity to dive into it. 😄 Please correct me if I'm wrong here.

As I can see the "Plural-Forms" line you propose as a "solution" still exists in our latest version.

"Plural-Forms: nplurals=4; plural=(n%100==1 ? 1 : n%100==2 ? 2 : n%100==3 || n"
"%100==4 ? 3 : 0);\n"

I assume we just don't use them for specific strings. We should use gettext.ngettext() instead of _() for that strings for example here:

backintime/common/config.py

Lines 117 to 119 in 56ea86f

DAY: _('Day(s)'),
WEEK: _('Week(s)'),
YEAR: _('Year(s)')

Am I right so far?

I read through the GNU gettext docu about that plural form:

I couldn't find a (for me) sufficient description about the syntax in the "Plural-Forms" line in the po-files header.

@b100w11
Copy link

b100w11 commented Jul 28, 2023

Yes it seems that gettext.ngettext() should do the trick.

@buhtz
Copy link
Member Author

buhtz commented Jul 28, 2023

I was looking through the BIT screenshots on Weblate to find cases where the use of ngettext() is appropriate.

I do see only the Schedule drop-down menu.
grafik

Are you aware of other places or source strings? Keep in mind that there are cases where there is no other way to say "Day(s)", e.g. in a spin-box where the user can modify the value.
grafik

buhtz added a commit that referenced this issue Aug 7, 2023
Fixing minor issues with source strings and add Plural Forms support.

Fix #1465
Fix #1488
@buhtz
Copy link
Member Author

buhtz commented Aug 7, 2023

Hello Vanja,
the "Schedule drop-down menu" now support the Plural Forms. I couldn't find another location in the UI where we could use Plural Forms. Please let me know if you find one.

You won't see the effect in Slovenian, yet. I will synchronize the translations from Weblate and the modified source strings here in the repository in the next days. After this is done you should see multiple plural forms in the weblate frontend; e.g. here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants