[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug-gettext] Problem with mixing plural and simgle form
From: |
Marian Cavojsky |
Subject: |
[bug-gettext] Problem with mixing plural and simgle form |
Date: |
Wed, 1 Feb 2012 09:02:21 +0100 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
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ý
- [bug-gettext] Problem with mixing plural and simgle form,
Marian Cavojsky <=