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

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

Re: Date/Number translations


From: Bruno Haible
Subject: Re: Date/Number translations
Date: Fri, 4 Jul 2008 00:53:26 +0200
User-agent: KMail/1.5.4

Maciej Piechotka wrote:
> Is it possible to translate in Gettext the numbers/date? Ie. to
> transform 1000.92 into 1.000,92 if locales requires it.

You don't need gettext for this. If you have

   double x = 1000.92;

and want some code that will print out "1,000.92" in a German locale, this code
will do it:

   setlocale (LC_ALL, ""); // LC_CTYPE and LC_NUMERIC would be sufficient
   printf ("%d\n", x);

If what you have is "1000.92" as a string, then you can convert it to a
'double' by use of the gnulib module 'c-strtod' [1].

For dates it is similar; look at the strftime function. See [2], [3] for
details.

Bruno


[1] http://www.gnu.org/software/gnulib/MODULES.html#module=c-strtod
[2] http://www.opengroup.org/susv3/functions/printf.html
[3] http://www.opengroup.org/susv3/functions/strftime.html





reply via email to

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