i18n: when 0 likes or reshare displaied, translations says "One" #745

Open
opened 2020-04-11 18:47:48 +00:00 by floreal · 11 comments
floreal commented 2020-04-11 18:47:48 +00:00 (Migrated from github.com)

An Image worth more than a description:
image
See templates/posts/details.rs.html#L82

  • Plume version: master

  • Operating system: Linux

  • Web Browser: Firefox

<!-- Describe your bug, explaining how to reproduce it, and what was expected --> An Image worth more than a description: ![image](https://user-images.githubusercontent.com/386442/79052177-f479fb80-7c34-11ea-968b-8f7f31c3fcb9.png) See [templates/posts/details.rs.html#L82](https://github.com/Plume-org/Plume/blob/master/templates/posts/details.rs.html#L82) - **Plume version:** master - **Operating system:** Linux - **Web Browser:** Firefox
elegaanz commented 2020-04-12 15:46:36 +00:00 (Migrated from github.com)

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.

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.
floreal commented 2020-04-13 12:23:37 +00:00 (Migrated from github.com)

image

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 ?

![image](https://user-images.githubusercontent.com/386442/79119690-43d53e80-7d91-11ea-861c-7f1b48e119e8.png) As i can see here are the entries in the translation files: en.po: ```gettext msgid "One like" msgid_plural "{0} likes" msgstr[0] "" msgstr[1] "" ``` fr.po: ```gettext msgid "One like" msgid_plural "{0} likes" msgstr[0] "Un like" msgstr[1] "{0} likes" ``` where does macro i18n!() comes from ?
elegaanz commented 2020-04-13 12:51:22 +00:00 (Migrated from github.com)

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…

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…
KitaitiMakoto commented 2020-04-30 13:58:53 +00:00 (Migrated from github.com)

Unfortunately, Plural-Forms settings was overwritten...

% rg Plural-Forms ~/host/Downloads/fr.po
13:"Plural-Forms: nplurals=2; plural=(n > 1);\n"
Unfortunately, Plural-Forms settings was overwritten... % rg Plural-Forms ~/host/Downloads/fr.po 13:"Plural-Forms: nplurals=2; plural=(n > 1);\n"
elegaanz commented 2020-04-30 14:17:57 +00:00 (Migrated from github.com)

Noooooo!

Then there are two solutions I can see:

  • editing this .po file in build.rs ouselves, at every compilation.
  • signaling the issue to Crowdin so that they can fix it.

And they are not mutually exclusive, we can do both.

Noooooo! Then there are two solutions I can see: - editing this .po file in `build.rs` ouselves, 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"

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"
KitaitiMakoto commented 2020-05-02 04:52:28 +00:00 (Migrated from github.com)

Oh, really? Thank you for important information.

Oh, really? Thank you for important information.
elegaanz commented 2020-05-02 10:07:24 +00:00 (Migrated from github.com)

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"

I feel stupid right now, for not noticing it before… 😅

> 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" I feel stupid right now, for not noticing it before… :sweat_smile:
floreal commented 2020-05-03 11:16:41 +00:00 (Migrated from github.com)

Would it work with that?

msgid "One like"
msgid_plural "{0} likes"
msgstr[0] "Aucun like"
msgstr[1] "Un likes"
Would it work with that? ``` msgid "One like" msgid_plural "{0} likes" msgstr[0] "Aucun like" msgstr[1] "Un likes" ```
elegaanz commented 2020-05-03 12:47:57 +00:00 (Migrated from github.com)

Maybe, because the header says nplurals=2, so there may be two different plurals for French if I read this correctly

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.

`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): ```po "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.
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: Plume/Plume#745
No description provided.