bug-gettext
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-gettext] Problem with mixing plural and simgle form


From: Perlover
Subject: Re: [bug-gettext] Problem with mixing plural and simgle form
Date: Wed, 1 Feb 2012 11:41:30 +0100

Dear Marián!

Why the gettext should decide the gettext( "Hello, world!\n" ) as the
ngettext( "Hello, world!\n", "Hello, worlds!\n", 1) by default?
It's very strange. First, i think we as developers should not mix
plural phrases and not plural ones.
Ans as rules plural forms have a digital placeholders (for example as
"%d" or "%i")

I see here some workarounds as following:

1) You need use for not plural form as other phrase or for plural
forms other phrases. For example:

printf( ngettext( "Hello, the world!\n", "Hello, %d worlds!\n", 2) );

2) You can change your plural formula
For example:
"Plural-Forms: nplurals=4; plural=(n==1) ? 2 : (n>=2 && n<=4) ? 3 : 1;\n"

and have in your PO file lines:

msgstr[0] "1 - Ahoj, svet!\n"
msgstr[1] "0 - Ahoj, svety!\n"
msgstr[2] "1 - Ahoj, svet!\n"
msgstr[3] "2 - Ahoj, svety!\n"

But change the gettext standard because you think that not plural form
is as plural with number 1 i don't understand. In the World there are
many languages and there may be language where not plural form is
listen as plural form for example. And your situation is bad
development of gettext phrases as i think

Best regards, Perlover


2012/2/1 Marian Cavojsky <address@hidden>:
> Hi.
>
> I have a problem with translations where are mixing single and plural forms.
>
> I have test program in c:
> $ cat testgettext.c
> // Test bug in gettext mixing plural and single form
>
> #include <libintl.h>
> #include <locale.h>
> #include <stdio.h>
> #include <stdlib.h>
> int main(void)
> {
>  setlocale( LC_ALL, "" );
>  bindtextdomain( "testgettext", "/usr/share/locale" );
>  textdomain( "testgettext" );
>  printf( gettext( "Hello, world!\n" ) );
>  printf( ngettext( "Hello, world!\n", "Hello, worlds!\n", 2) );
>  exit(0);
> }
> $ ----------------------------------
>
> $ xgettext -d testgettext -s -o testgettext.pot testgettext.c
> $ msginit -l sk -o testgettext.po -i testgettext.pot
>
> with modified po file for slovak language:
>
> $ cat testgettext.po
> # Slovak translations for testgettext package.
> # Copyright (C) 2012 THE PACKAGE'S COPYRIGHT HOLDER
> # This file is distributed under the same license as the PACKAGE package.
> #  Marian Cavojsky, 2012.
> #
> msgid ""
> msgstr ""
> "Project-Id-Version: testgettext 1\n"
> "Report-Msgid-Bugs-To: \n"
> "POT-Creation-Date: 2012-01-31 14:39+0100\n"
> "PO-Revision-Date: 2012-02-01 08:30+0100\n"
> "Last-Translator:  <address@hidden>\n"
> "Language-Team: Slovak\n"
> "Language: sk\n"
> "MIME-Version: 1.0\n"
> "Content-Type: text/plain; charset=UTF-8\n"
> "Content-Transfer-Encoding: 8bit\n"
> "Plural-Forms: nplurals=3; plural=(n==1) ? 1 : (n>=2 && n<=4) ? 2 : 0;\n"
>
> #: testgettext.c:12 testgettext.c:13
> #, c-format
> msgid "Hello, world!\n"
> msgid_plural "Hello, worlds!\n"
> msgstr[0] "0 - Ahoj, svety!\n"
> msgstr[1] "1 - Ahoj, svet!\n"
> msgstr[2] "2 - Ahoj, svety!\n"
> $ ----------------------------------
>
> $ msgfmt -c -v -o testgettext.mo testgettext.po
> 1 preložená správa.
> $ sudo cp testgettext.mo /usr/share/locale/sk/LC_MESSAGES/testgettext.mo
> $ ./testgettext
> 0 - Ahoj, svety!
> 2 - Ahoj, svety!
>
> For single form (line 12) translation code used message with index "0" and not
> "1" which is written in plural-forms formula.
>
> Correct output:
> $ ./testgettext
> 1 - Ahoj, svet!
> 2 - Ahoj, svety!
>
> Either do not mix single form msgid with messages for plural forms, or really
> use the plural-forms formula for single form messages.
>
> My version of gettext:
> $ equery l gettext
>  * Searching for gettext ...
> [IP-] [  ] sys-devel/gettext-0.18.1.1-r1:0
> $ gettext --version
> gettext (GNU gettext-runtime) 0.18.1
>
> Please send the answer to my e-mail address. I am not in mailing-list.
>
> --
> Marián Čavojský
>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]