[Qt-interest] javascript and locale?
Bo Thorsen
bo at fioniasoftware.dk
Thu Oct 13 17:51:03 CEST 2011
Den 12-10-2011 12:27, Frank Hemer skrev:
> On Wednesday 12 October 2011 05:05:36 Girish Ramakrishnan wrote:
>> On Tue, Oct 11, 2011 at 10:55 PM, Frank Hemer<frank at hemer.org> wrote:
>>> Hello,
>>>
>>> I'm trying to use toLocaleString () javascript methods (for i.e. Date)
>>> but cannot find howto setup the locale.
>>> QLocale::setDefault (...) seems not to have any effect, only on linux the
>>> system locale itself seems to affect the result.
>>>
>>> Is this not supported or maybe a bug?
>>
>> Before I start, don't take this is a definitive answer :-)
>>
>> I think it's not supported. AFAICT, QLocale and QtScript's locale
>> stuff don't tie into each other in any way. Have you tried calling
>> setlocale() directly? I also see that Number.toLocaleString() appears
>> to be unimplemented in JSC (it has a FIXME...)
>
> Well, thats what I tried so far. Setting the locale via environment works fine
> regarding the Date.toLocaleString () - but as you have mentioned,
> Number.toLocaleString () does nothing. Seems like I have to implement my own
> workaround:-(
>
> However thanks:-) for the info - I'll file a bug report.
That's the right approach. And we can only hope that at some point soon,
QML starts feeling more complete. For something that should be the base
of Qt 5, it's in a pretty sad state.
The other (and better) solution for you is to create a patch that fixes
this and get it into Qt. Then you are sure that it will work in future
releases.
For now, you can export functions from c++ that calls the locale aware
methods and return the result to your QML/JS code.
Bo Thorsen,
Fionia Software.
--
Expert Qt and C++ developer for hire
Contact me if you need expert Qt help
http://www.fioniasoftware.dk
More information about the Qt-interest-old
mailing list