Use QLocale instead of QLocale::system
AbandonedPublic

Authored by aacid on Feb 23 2018, 12:36 AM.

Details

Reviewers
apol
ilic
Summary

That makes it work if someone called QLocale::setDefault like kxmlgui does when setting an individual app language

Test Plan

Diff Detail

Repository
R240 Extra CMake Modules
Branch
master
Lint
No Linters Available
Unit
No Unit Test Coverage
aacid created this revision.Feb 23 2018, 12:36 AM
Restricted Application added projects: Frameworks, Build System. · View Herald TranscriptFeb 23 2018, 12:36 AM
Restricted Application added subscribers: Build System, Frameworks. · View Herald Transcript
aacid requested review of this revision.Feb 23 2018, 12:36 AM
apol accepted this revision.Feb 23 2018, 11:33 AM
apol added a subscriber: apol.

I'm guessing that QLocale::default defaults to QLocale::system?

This revision is now accepted and ready to land.Feb 23 2018, 11:33 AM
kossebau added a subscriber: kossebau.EditedFeb 23 2018, 9:51 PM

Might be an idea indeed to switch to default locale instead of system one. Can you tell at which point the system one is estimated, and based on what?

Grepping QLocale::system on lxr.kde.org there are some hits, those might need some fixing as well then for consistency (via notification to app maintainers to fix themselves carefully)?

Still leaves the race condition between the installed hooks. It would have assumed the static init of the kxmlgui lib is only run after the ones of those using the ECMQmLoader, and the registered hooks would be processed in order of registration. So the switchlanguage one is only run after the qmloader ones.

IIRC all this would be not a problem if we were able tun run the switchlanguage hook before the QApp instance is created. Thus setting the LANGUAGE env var to our desire, and then letting things roll as usual. And it is just that things are delayed because the convenience code to find the UI language setting needs QStandardPaths & Co. set, which only is during the QApp instance creation. Anybody can confirm?

I just see there is also a QEvent::LocaleChange event type. Perhaps there could be some listener on that event, which reinstalls an updated translator instance on a change? First event loop might be too late though, given some UI objects have already been created and most KDE code does not support UI locale change.

If this change goes in, then API dox pf ECMPoQmTools should see some mention of this behaviour (change). So people can rely on it.

there's a new revision of D10757 that shouldn't need this at all.

aacid abandoned this revision.Feb 25 2018, 10:46 AM