Fix dates being on the wrong locale when setting an application language individually
Needs ReviewPublic

Authored by aacid on Mon, Aug 12, 10:32 PM.
This revision needs review, but there are no reviewers specified.



We were only setting LANGUAGE, but that does not set LC_TIME so the time was still
set to the "user" locale, we now set LC_ALL to switch the application completely to that language

Note we are not actually switching the posix locale, just all the
QLocale/ki18n related internals, strftime would still use the user
original locale. This is also the reason we don't really need to pass a
valid locale name to LC_ALL (i.e. we're giving it "ru" instead of
"ru_RU.UTF-8"), since the only thing we need to do is convince QSystemLocaleData::readEnvironment
and giving it "ru" is enough

Diff Detail

R263 KXmlGui
No Linters Available
No Unit Test Coverage
Build Status
Buildable 15383
Build 15401: arc lint + arc unit
aacid created this revision.Mon, Aug 12, 10:32 PM
Restricted Application added a project: Frameworks. · View Herald TranscriptMon, Aug 12, 10:32 PM
Restricted Application added a subscriber: kde-frameworks-devel. · View Herald Transcript
aacid requested review of this revision.Mon, Aug 12, 10:32 PM

hmmm, now that i think about it LC_ALL probably needs a .UTF-8 suffix or something to be correct

But OTOH this is working fine for me.


asemke added inline comments.Sat, Aug 17, 9:19 AM

does this test work? The name of the month is "январь" in russian, not "января".

aacid added inline comments.Tue, Aug 20, 9:10 PM

Yes, it may surprise you, but i did actually run the tests before submitting this code change.

ltoscano added inline comments.
aacid updated this revision to Diff 64176.Tue, Aug 20, 9:44 PM
aacid edited the summary of this revision. (Show Details)
aacid removed a subscriber: ltoscano.

update commit log

asemke added inline comments.Fri, Aug 23, 7:14 AM

there is no declension in Russian for the nominative case. The name of the month is январь and not января, but it is первого января (on January 1st) and not первого январь. - QLocale must return the name of the month, meaning the nominative case and not one of its declensions.


The question was rethoric. I was rather surprised about the validnes of the check you did here.

yurchor added inline comments.

AFAIK this is broken on Qt level. Cf. calendar widget in KOrganizer (Ukrainian)

There are new specifiers for the primary and alternative month names in glibc but Qt does not implement them (must be something like "LLLL YYYY" instead of "MMMM YYYY" in formatting). Rafal Luzynski (the author of the glibc patch) in a private message (2018-01-25) promised me to send the patch for Qt but this has not happened yet.

asemke added inline comments.Fri, Aug 23, 9:15 AM

This is maybe not Qt but the locale defintion files which are probably distro specific. I just checked on SLES and on openSuse.

for ukrainian:

LC_TIME=uk_UA.UTF-8 locale mon

for russian:

LC_TIME=ru_RU.UTF-8 locale mon

This is, except of capital letters for ru_RU, correct.

On Mac I get however




which is possessive case and is wrong if you reffer to the name of the month itself.

@aacid on your distribution you'll most probably get the same output as on my Mac. Under the assumption that Qt evaluates the locale definition files, your test will probably fail on other distributions which do this correctly.

asemke added inline comments.Fri, Aug 23, 9:22 AM

@aacid the discussion about declensions in slawic languages is not relevant to your patch I'd say. Maybe it's better to use in the test a language like German or any other languages where we don't have this additional complication.