bug-gnu-utils
[Top][All Lists]
Advanced

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

Re: [Translation-i18n] Memory management in gettext?


From: Chris Scaife
Subject: Re: [Translation-i18n] Memory management in gettext?
Date: Wed, 15 Sep 2010 05:52:52 +1200

Hey, thanks for that idea Alex, I hadn't quite fathomed how I might
use the "context" gettext functions. Your suggestion makes it much
clearer :)

What I was using "pluralization" for is to select different numerical
template strings for outputting numbers depending on the value. By way
of example to show very different for large amounts and small amounts
and debts when dealing with money. i.e. the following formatting
changes are all done with translatable template strings.

$> export LANG=en_NZ.UTF-8
$> ./a.out 0.20 -0.20 12345678
0.20 = 20ยข
-0.20 = ($ 0.20)
12345678 = $ 12,345,678.00

On 15 September 2010 00:17, Alexander Dupuy <address@hidden> wrote:
> Chris Scaife wrote:
>>
>> In my project I wanted to differentiate on negative values for
>> ngettext and dngettext pluralization. Sadly they only work with
>> unsigned long integers. Part of the problem is that on some systems
>> this can be 32 bit and on others 64 bit. I'm hoping to suggest to the
>> GNU gettext team that we could use signed values instead. For the time
>> being, I've wrapped my pluralizing numbers that are above 10000 into
>> the space 10000 - 19999... and then negative values can be discovered
>> by testing > 20000 in the .po pluralization formula. It's not an
>> elegant solution so if anyone has alternative suggestions I would love
>> to hear :)
>
> Another possibility would be that rather than mapping numbers into a
> particular range (yours is probably fine but one never knows) you could have
> your function make two separate calls to [d]ngettext, with different message
> contexts (negative numbers would have " (negative values)" appended to the
> default context or something like that).
>
> This is a little inelegant for the translators, in that the .po file will
> contain the same message twice (with different contexts) but at least it
> will be very explicit what is going on, and in any language where a negative
> value requires different translation, it will be quite clear to the
> translator what needs to be done.
>
> @alex
>
> --
> mailto:address@hidden
>
>



reply via email to

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