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

Use translation with plurals for x days/weeks/months ago #112

Closed
rluzynski opened this issue Mar 19, 2015 · 6 comments
Closed

Use translation with plurals for x days/weeks/months ago #112

rluzynski opened this issue Mar 19, 2015 · 6 comments

Comments

@rluzynski
Copy link
Contributor

Translation of the relative date format telling when an issue occurred ("yesterday", "last week", "3 days ago", "4 years ago") may be impossible for some languages because of the following wrong assumptions:

  • it is not true that a simple concatenation of "Last " and "week"/"month"/"year" can be correctly translated because in some languages "last" may have to be male/female/neutral depending on the grammatical gender of "week"/"month"/"year";
  • it is not true for some languages that converting singular to plural is as simple as appending "s";
  • for these languages it is also not true that there is another suffix instead of "s" but one and common for all words;
  • the plural forms may be irregular;
  • there may be multiple plural forms.

My suggestion is that instead of a complex algorithm which first determines the translated singular name of the period (day, month, week, year), and then either prepends it with a translated word "Last" or applies the translated format "{0:d} {1!s}s ago" you can achieve the correct result simply using ngettext with the following pairs of singular/plural:

  • singular="Yesterday", plural="%d days ago";
  • singular="Last week", plural="%d weeks ago";
  • singular="Last month", plural="%d months ago";
  • singular="Last year", plural="%d years ago";

Isn't it simple? The function fancydate is in the source file tools.py.

@alick
Copy link

alick commented Nov 1, 2015

Recent discussion on fedora-trans list suggests the current plural handling is incorrect.

Please consider to reopen this issue.

Email content quoted as below for your convenience:

Please warn the gnome-abrt upstream the way they handle plural will break the languages where
the first form is not one. [1]

For example, French's "singular" form includes 0 and 1 (while in English, 0 is plural).
So if function outputs 0, the French equivalent of "Last Week" will be used, which may be wrong.

And as for Chinese, the thing you translated become
msgstr[0] "上周\n"
"\n"
"{0:d} 周前"

a three-lined string no matter what function returned.

If the function returns 1, user will see:
上周

1 周前

If the function return 3, user will see:
上周

3 周前

If the upstream does not fix it in time, I suggest you go with

{0:d} weeks ago --> {0:d} 周前

Reference:

  1. http://www.unicode.org/cldr/charts/latest/supplemental/language_plural_rules.html

@rluzynski
Copy link
Contributor Author

@alick, thank you for your remark. Are you able to reopen the issue or open a new one?

I'm sorry but I don't know anything about Chinese language so I am hardly able to solve the problem. Is it because Chinese does not have plural/singular number? Please explain how does it appear now. Is it possible to translate into Chinese such expressions like "Last week" / "n weeks ago" and "Yesterday" / "n days ago"? Is it a limitation of zanata that it cannot handle a translation if an English singular and plural strings are intentionally different? Or is zanata absolutely right and we have a bug in gnome-abrt? Are you able to provide a patch or describe the correct solution which also preserves this fancy appearance in English?

@definite
Copy link

definite commented Nov 2, 2015

@rluzynski
Chinese, Japanese and Korean (CJK) do not have plural, that's the reason Zanata and lokalize only provides one entry for language without plural. In fact, in lokalize, you won't be able to see "Last week", as it only shows the plural form "{0:d} weeks ago" and hide the singular. So for CJK, it will only show the msgstr[0].

The real problem will be appear in Russian, whose Plural form is

nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);

The first form includes 1, 21, 31, ...
So if the event happen 21 months ago, you will see it as "last month".

@definite
Copy link

definite commented Nov 2, 2015

Hmm, for Russian, perhaps thing is not as bad as I originally though.
For experienced translators, they know that the first form also includes 21,31 etc and translate accordingly.

But for inexperienced translators, they may translate as-is. So the conservative choice is used some thing like:

 msgid "{0:d} week ago"
 msgid_plural "{0:d} weeks ago"

@rluzynski
Copy link
Contributor Author

Thank you, @definite and @alick, for explaining and for pointing out the case with Russian. Actually, the Russian users will never see the bug with "21 months ago" because instead they will see "Last year" or "2 years ago", similarly they will never see "21 weeks" nor "21 days ago". But they will see "21 years ago"... in year 2036. But that's not an excuse.

Indeed, it looks like we have to handle the case of 1 separately and explicitly, without relying on ngettext. I will try to provide a patch.

Unfortunately, I cannot reopen the issue but I hope it is not necessary.

@definite
Copy link

definite commented Nov 3, 2015

Thanks for rapid reply!

----- Original Message -----

Thank you, @definite and @alick , for explaining and for pointing out the
case with Russian. Actually, the Russian users will never see the bug with
"21 months ago" because instead they will see "Last year" or "2 years ago",
similarly they will never see "21 weeks" nor "21 days ago". But they will
see "21 years ago"... in year 2036. But that's not an excuse.

Indeed, it looks like we have to handle the case of 1 separately and
explicitly, without relying on ngettext . I will try to provide a patch.

Unfortunately, I cannot reopen the issue but I hope it is not necessary.


Reply to this email directly or view it on GitHub .

Ding-Yi Chen
Software Engineer
Globalization Group
DID: +61 7 3514 8239
Email: dchen@redhat.com

Red Hat, Asia-Pacific Pty Ltd
Level 1, 193 North Quay
Brisbane 4000
Office: +61 7 3514 8100
Fax: +61 7 3514 8199
Website: www.redhat.com

Red Hat, Inc.
Facebook: Red Hat APAC | Red Hat Japan | Red Hat Korea | JBoss APAC
Twitter: Red Hat APAC | Red Hat ANZ
LinkedIn: Red Hat APAC | JBoss APAC

rluzynski added a commit to rluzynski/gnome-abrt that referenced this issue Nov 3, 2015
It turned out that we can't fully rely on ngettext() for some
languages which don't have plurals (Chinese, Japanese, Korean)
or use the singular form for some plural cases (21, 31, ... in
Russian).

Fixes abrt#112
jfilak pushed a commit that referenced this issue Nov 3, 2015
It turned out that we can't fully rely on ngettext() for some
languages which don't have plurals (Chinese, Japanese, Korean)
or use the singular form for some plural cases (21, 31, ... in
Russian).

Fixes #112

Signed-off-by: Jakub Filak <jfilak@redhat.com>
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 a pull request may close this issue.

3 participants