[Qgis-developer] Locale in Python console

Chris Crook ccrook at linz.govt.nz
Wed Mar 3 16:30:34 EST 2010


Hi Martin

I think I won't try the change ... I doubt I could give good coverage for testing.  But from your suggestion it looks like the code I need to use is

>>> from PyQt4.QtCore import QSettings
>>> locale = QSettings().value("locale/userLocale").toString()

which gives me exactly what I want!

Thanks
Chris
________________________________________
From: Martin Dobias [wonder.sk at gmail.com]
Sent: 04 March 2010 10:15
To: Chris Crook
Cc: qgis-developer at lists.osgeo.org
Subject: Re: [Qgis-developer] Locale in Python console

On Wed, Mar 3, 2010 at 9:05 PM, Chris Crook <ccrook at linz.govt.nz> wrote:
> Hi
>
> I'm trying to determine the users Locale in the python console.  I've changed the quantum locale to "fr" and restarted, and as expected menus etc are French.  However this does not seem to be reflected in the python console window:
>
>>>> from PyQt4.QtCore import QLocale
>>>> q = QLocale()
>>>> q.name()
> PyQt4.QtCore.QString(u'en_NZ')
>>>>
>
> Am I using the wrong function to determine the locale()?  Or is this a problem with the Python console.  And if so, will it also be a problem with plugins?

Hi

from what I see in src/app/main.cpp initialization code, qgis only
installs translators for the language, but it doesn't change the
locale. It could be easily done by adding
QLocale::setDefault(QLocale(code)) to the initialization. I'm not sure
about the impact of this addition as it overrides various global
settings such as parsing of numbers, so I'm not going to play with it
right now (no time for it either). But it's worth trying out and
testing with several locales - to find out whether things will work.
So if you have some time you might give it a try (and post a patch).

Cheers
Martin
______________________________________________________________________________________________________

This message contains information, which is confidential and may be subject to legal privilege. 
If you are not the intended recipient, you must not peruse, use, disseminate, distribute or copy this message.
If you have received this message in error, please notify us immediately (Phone 0800 665 463 or info at linz.govt.nz) and destroy the original message.
LINZ accepts no responsibility for changes to this email, or for any attachments, after its transmission from LINZ.

Thank you.
______________________________________________________________________________________________________


More information about the Qgis-developer mailing list