Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Global Locale support

Moderators: larsivi kris

Posted: 03/13/08 16:14:12

I can set locale support for Stdout etc, but this doesn't affect other parts of the system. Is there a way of setting this on a global scale so all convertions etc is done using this locale?

Author Message

Posted: 03/13/08 22:37:50

Not really, although you could configure up a global instance for use in all your output channels.

Posted: 03/14/08 02:00:13

Which other parts of the system do you have in mind, simhau?

Posted: 03/18/08 12:21:08

For example Float.toString(1.4) should print "1,4" in my locale, not "1.4".

Now it has to be something like this: auto l = new Locale; l("{}", 1.4)

Posted: 03/18/08 12:23:39

And of course the other way around..

Float.toFloat("1,4") throws an error. I have to manually replace the , with .

Posted: 03/18/08 16:59:53

Oh I see.

We decided to avoid tying the locale processing to the lower levels of conversion, since that would add a significant amount of code and data to programs that don't use locale specifics. Basically, locale is optionally enabled globally only at the higher level of Print, and derivatives such as Stdout and Stderr.

Posted: 03/19/08 16:05:19

Is it perhaps possible to add this kind of functionality with a compile-time switch? That would eliminate the bloat for normal applications, but ease the development of locale applications, right?