Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QgsApplication.instance().locale() does NOT return same locale if qgis started with --lang option #37620

Open
rduivenvoorde opened this issue Jul 6, 2020 · 3 comments
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! PyQGIS Related to the PyQGIS API

Comments

@rduivenvoorde
Copy link
Contributor

QGIS has some 'startup options' if started from the commandline.

One I often use is the --lang nl one, to (temporarily) start QGIS in dutch to check for example what a menu looks like in dutch.

Plugins (created with the plugin builder) for what I know check the language using (for example in Python Console):

QgsApplication.instance().locale()

BUT that (in case of starting up with --lang option) does not show the same 2char code.
Also note that in the settings at that moment the 'Ignore System Locale' is not checked and does not resemble current situation. For example below I run qgis --lang nl on an english system (it looks like the locale for numbers is changed there):

Screenshot-20200706111115-1023x269

To reproduce:

  • on english system
  • start QGIS qgis --lang nl in cli
  • see that QGIS interface is dutch
  • in python console do: QgsApplication.instance().locale() and see it shows en

@m-kuhn maybe has something to do with the work for the swiss to split up locale/language and locale for the use of numbers etc ?

NOTE2: if you do this via the Settings: all is working:

Screenshot-20200706111648-1025x256

Maybe that could show BOTH the system locale AND the set locale?

@rduivenvoorde rduivenvoorde added the Bug Either a bug report, or a bug fix. Let's hope for the latter! label Jul 6, 2020
@elpaso
Copy link
Contributor

elpaso commented Jul 6, 2020

@rduivenvoorde IMO this is not a bug. We have different independent options to configure the GUI translation and the locale.

--lang set the translation and not the locale, we might need an additional option to change locale and set the omit group separator options.

@m-kuhn
Copy link
Member

m-kuhn commented Jul 6, 2020

The same also happens also the OS is configured to a language and the qgis settings are left to the default. Default plugin builder generated code will fail.

What would be good is a more stable code for plugin builder generated code to obtain the language.

@rduivenvoorde
Copy link
Contributor Author

rduivenvoorde commented Jul 6, 2020

@elpaso I agree for some part, though that is probably too much (to add even more startup options)

And the plugin builder apparently changed! See https://github.com/g-sherman/Qgis-Plugin-Builder/blob/master/plugin_templates/toolbutton_with_dialog/template/module_name.tmpl#L51

And QSettings().value('locale/userLocale', QLocale().name()) (from plugin code) returns 'nl' if QGIS is started with --lang option, so for plugins this is fixed/fixable.

What is unclear to me is how the Settings part in the dialog should behave...

As you see in the first screenie, the (disabled! in grey) options do not represent the current state. While I started with --lang nl (which should mean: (only) language NL, locale still 'whatever') the two (disabled dropdowns) show: 'Vertaling'/'Language' is english and 'Landinstelling'/'Locale' as Dutch.

I think(!) that if started with --lang option, the checkbox 'Override System Locale' should be checked and (only) the 'User interface translation' dropdown should then reflect the --lang language?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! PyQGIS Related to the PyQGIS API
Projects
None yet
Development

No branches or pull requests

4 participants