[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Emacs i18n
From: |
Paul Eggert |
Subject: |
Re: Emacs i18n |
Date: |
Fri, 8 Mar 2019 23:54:28 -0800 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.1 |
Richard Stallman wrote:
Here's an idea for a scheme general enough to handle Russian as well.
That idea's use of "-masc", "-fem", and "-neut" suggests that you misunderstood
the problem with translating format strings like "%d items" into Russian.
Russian has three plural forms useful for translating a string that formats an
integer N. One form is for when (N%10 == 1 && N%100/10 != 1), one is for when (2
<= N%10 && N%10 <= 4 && N%100/10 == 1), and one is for everything else. So the
form depends on N, not on whether the translation of the word "items" is
masculine or feminine or whatever. Other languages have other rules, with
varying levels of complexity; for example, Arabic has six different plural forms.
GNU gettext deals with this at the translation level, so that ordinary programs
can just use a function like ngettext to translate an English-language format
with two plural forms. Emacs Lisp should do something similar: we shouldn't try
to reinvent this wheel.
Here's an example, taken from GNU dd. The C source code contains the two English
forms and looks something like this:
fprintf (stderr,
ngettext ("%"PRIuMAX" byte copied, %s, %s",
"%"PRIuMAX" bytes copied, %s, %s",
w_bytes),
w_bytes, delta_s_buf, bytes_per_second);
And the ru.po file (which Russian translators edit) looks like this:
"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4
&& (n%100<10 || n%100>=20) ? 1 : 2);\n"
...
#: src/dd.c:822
#, c-format
msgid "%<PRIuMAX> byte copied, %s, %s"
msgid_plural "%<PRIuMAX> bytes copied, %s, %s"
msgstr[0] "%<PRIuMAX> байт скопирован, %s, %s"
msgstr[1] "%<PRIuMAX> байта скопировано, %s, %s"
msgstr[2] "%<PRIuMAX> байт скопировано, %s, %s"
Each of the three Russian plural forms is supported, and the right one is chosen
by the translation system without the programmer having to know how Russian
plural forms work. For more about this, please see the GNU gettext manual, such
as this web page:
https://www.gnu.org/software/gettext/manual/html_node/Plural-forms.html
PS. Although the email from Elias said "From: =?UTF-8?Q?Elias_M=C3=A5rtenson?="
which displays correctly as "Elias Mårtenson", your reply said "To: Elias
=?iso-8859-1?Q?M=C3=A5rtenson?=" which displays incorrectly as "Elias
MÃ¥rtenson". It looks like there's a bug in your email client, or in your
configuration of it, a bug that munges names of your email correspondents.
- Re: Emacs i18n, (continued)
- Re: Emacs i18n, Paul Eggert, 2019/03/06
- Re: Emacs i18n, Eli Zaretskii, 2019/03/06
- Re: Emacs i18n, Paul Eggert, 2019/03/06
- Re: Emacs i18n, Eli Zaretskii, 2019/03/06
- Re: Emacs i18n, Richard Stallman, 2019/03/07
- Re: Emacs i18n, Eli Zaretskii, 2019/03/08
- Re: Emacs i18n, Richard Stallman, 2019/03/07
- Re: Emacs i18n, Elias Mårtenson, 2019/03/07
- Re: Emacs i18n, Eli Zaretskii, 2019/03/08
- Re: Emacs i18n, Richard Stallman, 2019/03/08
- Re: Emacs i18n,
Paul Eggert <=
- Re: Emacs i18n, Eli Zaretskii, 2019/03/09
- Re: Emacs i18n, Richard Stallman, 2019/03/09
- Re: Emacs i18n, Paul Eggert, 2019/03/10
- Re: Emacs i18n, Richard Stallman, 2019/03/10
- Re: Emacs i18n, Paul Eggert, 2019/03/11
- Re: Emacs i18n, Richard Stallman, 2019/03/11
- Re: Emacs i18n, Richard Stallman, 2019/03/11
- Re: Emacs i18n, Yuri Khan, 2019/03/10
- Re: Emacs i18n, Richard Stallman, 2019/03/09
- Re: Emacs i18n, Paul Eggert, 2019/03/10