lxqt / lxqt-config

Tools to configure LXQt and the underlying operating system
https://lxqt.github.io
GNU Lesser General Public License v2.1
79 stars 60 forks source link

[lxqt-config-locale] LANGUAGE variable not set #975

Open gfgit opened 5 months ago

gfgit commented 5 months ago
Expected Behavior

All relevant language environment variables are set correctly and are coherently, unless explicitly a custom setup is specifically wanted by the user.

Current Behavior

LXQt Panel's FancyMenu plugin is half translated and half original after changing system locale from English to Italian.

fancymenu_kde_plasma_buttons

This happens because Qt libraries sometimes use LANGUAGE variables as highest priority over LANG, sometimes the other way round. See qlocale_unix.cpp#L104.

This leads QLocale::system().name() to return en_US even though I've chosen "Italian" in the config dialog. This code is called for example by lxqttranslator.cpp#L135 So it's pretty much all LXQt applications.

The QtXdg library instead follows another priority order. See qtxdg/xdgdesktopfile.cpp#L858 Here LANGUAGE variable is not even considered, the code checks in order: LC_MESSAGES, LC_ALL, LANG which in my setup are all set to it_IT.UTF-8 which is correct.

Possible Solution

Either set LANGUAGE to same value as LANG (don't know if it's correct for Unix docs) or change evaluation priority order to match Qt libraries

Steps to Reproduce (for bugs)
  1. Change from English to Italian
  2. Restart lxqt-panel
  3. Open FancyMenu
  4. Categories and apps are in Italian, special "virtual" categories are in English and so is the rest of the UI
Context

My environment on KDE Tuxedo 2:

~$ env | grep LC
LC_ADDRESS=it_IT.UTF-8
LC_NAME=it_IT.UTF-8
LC_MONETARY=it_IT.UTF-8
LC_PAPER=it_IT.UTF-8
LC_IDENTIFICATION=it_IT.UTF-8
LC_TELEPHONE=it_IT.UTF-8
LC_MEASUREMENT=it_IT.UTF-8
LC_TIME=it_IT.UTF-8
LC_NUMERIC=it_IT.UTF-8

~$ env | grep LANG
LANGUAGE=it
LANG=en_US.UTF-8

See LANG set to English which seems fine.

My environment in Ubuntu LXQt:

~$ env | grep LC
LC_MONETARY=it_IT.UTF-8
LC_MEASUREMENT=it_IT.UTF-8
LC_TIME=it_IT.UTF-8
LC_COLLATE=it_IT.UTF-8
LC_NUMERIC=it_IT.UTF-8

~$ env | grep LANG
LANGUAGE=en
GDM_LANG=en
LANG=it_IT.UTF-8

Here LANG is like LC_* but LANGUAGE is still English

System Information
gfgit commented 5 months ago

It's worth considering #506 while refactoring this code.