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

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

Re: Date/Number translations


From: Maciej Piechotka
Subject: Re: Date/Number translations
Date: Fri, 04 Jul 2008 02:49:53 +0200

On Fri, 2008-07-04 at 00:53 +0200, Bruno Haible wrote:
> 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
> 

Thanks for response. Do setlocale set the locale globally or per-thread?
If globally is there any possible of doing it with different locales on
different threads or do I need to synchronize it?

Regards

Attachment: signature.asc
Description: This is a digitally signed message part


reply via email to

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