[Qgis-developer] Locale in Python console

Martin Dobias wonder.sk at gmail.com
Wed Mar 3 16:15:20 EST 2010


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


More information about the Qgis-developer mailing list