Plume
Plume copied to clipboard
i18n: when 0 likes or reshare displaied, translations says "One"
An Image worth more than a description:
See templates/posts/details.rs.html#L82
-
Plume version: master
-
Operating system: Linux
-
Web Browser: Firefox
Can you try with another language than french to see if you can reproduce? Because it seems to work fine in English. So maybe the issue is more with the French translation.

As i can see here are the entries in the translation files:
en.po:
msgid "One like"
msgid_plural "{0} likes"
msgstr[0] ""
msgstr[1] ""
fr.po:
msgid "One like"
msgid_plural "{0} likes"
msgstr[0] "Un like"
msgstr[1] "{0} likes"
where does macro i18n!() comes from ?
We wrote i18n for Plume, it comes from the gettext-macros crate: https://github.com/Plume-org/gettext-macros/blob/main/src/lib.rs#L462
And judging by what I see, it is more an issue with the "Plural-Forms" header in the fr.po file, that is either incorrect, or not parsed correctly by the Rust gettext implementation…
Unfortunately, Plural-Forms settings was overwritten...
% rg Plural-Forms ~/host/Downloads/fr.po
13:"Plural-Forms: nplurals=2; plural=(n > 1);\n"
Noooooo!
Then there are two solutions I can see:
- editing this .po file in
build.rsouselves, at every compilation. - signaling the issue to Crowdin so that they can fix it.
And they are not mutually exclusive, we can do both.
Actually Crowdin is right about french using plurals for n > 1. Zero is singular in french, which means the correct translations would be msgstr[0] "{0} like" which means losing the all letters "Un"
Oh, really? Thank you for important information.
Actually Crowdin is right about french using plurals for
n > 1. Zero is singular in french, which means the correct translations would bemsgstr[0] "{0} like"which means losing the all letters "Un"
I feel stupid right now, for not noticing it before… :sweat_smile:
Would it work with that?
msgid "One like"
msgid_plural "{0} likes"
msgstr[0] "Aucun like"
msgstr[1] "Un likes"
Maybe, because the header says nplurals=2, so there may be two different plurals for French if I read this correctly
nplurals count how many variations there are, including singular, 2 is 1 singular plus 1 plural.
@floreal your proposition would not work :
- if like > 1 it returns "Un likes"
- else (so if likes ⩽1) it returns "Aucun like".
If we want to have "Aucun", "Un" or any number, there have to be 3 plurals (not that it requires changing all other french translation strings to have the same number of variations, and there is still the problem about Crowdin overwriting Plural-Forms):
"Plural-Forms: nplurals=3; plural=(n > 1 ? 2 : n);\n"
msgid "One like"
msgid_plural "{0} likes"
msgstr[0] "Aucun like"
msgstr[1] "Un like"
msgstr[2] "{0} likes"
(Not so) Short explanation of how plurals works in gettext :
nplurals describes how many variations there are. If its, say, 5, there are 5 variations, so each translations requieres to have msgstr[0] to msgstr[4].
plural is the formula that gives what msgstr has to be used, it must returns an integer < nplurals. For most languages it can be n != 1 or n > 1 as they have only 1 plural (and 1 singular), false would be considered as 0, and true as 1 (as usually done in C). For more complex plural forms, one can use <inequality> ? <if it was true> : <if it was false> formula, like a C inline if statement. Imbrication is possible as many as you want (see Russian version for how complex it can get). I'll name res what was returned by the formula
msgstr[res] is chosen as the correct translation, based on the return value of plural.