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: Sat, 18 Sep 2010 03:24:11 +1200

I tried the context gettext functions but I just didn't understand them, so
I settled on sticking a - sign
on the front of the word to translate whenever the value is negative. Thanks
for the idea anyway :)

Note: You can see this in action with my numeric test program where the word
"counter" is translated into a template
for rendering digits... Here some sample output. I hope the international
characters are maintained in this email, but the source code is all at
http://code.google.com/p/speaknumber/

<http://code.google.com/p/speaknumber/>Next I'm moving forward with my GUI
demo program that will let one experiment with number templates and their
translations interactively.


$ ./test.sh T_CHINA
test program is ./a.out
$ ./a.out 1956
1956 number = counter, financial = $ 19.56, template=$ 222,222.33
$ export LANG=zh_CN.utf-8
$ ./a.out 1956
1956 number = 仟九佰五拾六, financial = 仟玖佰伍拾陆, template=1仟1佰1拾0
$ ./a.out -1956
-1956 number = 负仟九佰五拾六, financial = 負仟玖佰伍拾陆, template=負1仟1佰1拾0
$ export LANG=en_NZ.UTF-8
$ ./a.out -1956
-1956 number = -counter, financial = ($ 19.56), template=($ 222,222.33)


On 15 September 2010 05:52, Chris Scaife <address@hidden> wrote:
> 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]