Changeset View
Changeset View
Standalone View
Standalone View
src/kswitchlanguagedialog_p.cpp
Show First 20 Lines • Show All 74 Lines • ▼ Show 20 Line(s) | 72 | { | |||
---|---|---|---|---|---|
75 | 75 | | |||
76 | if (languageCode.isEmpty()) { | 76 | if (languageCode.isEmpty()) { | ||
77 | settings->remove(qAppName()); | 77 | settings->remove(qAppName()); | ||
78 | } else { | 78 | } else { | ||
79 | settings->setValue(qAppName(), languageCode); | 79 | settings->setValue(qAppName(), languageCode); | ||
80 | } | 80 | } | ||
81 | } | 81 | } | ||
82 | 82 | | |||
83 | void addSetEnvVar(const char *envVarName, const QByteArray &value) | ||||
84 | { | ||||
85 | const QByteArray envVarValue = qgetenv(envVarName); | ||||
86 | if (envVarValue.isEmpty()) { | ||||
87 | qputenv(envVarName, value); | ||||
88 | } else { | ||||
89 | qputenv(envVarName, value + ':' + envVarValue); | ||||
90 | } | ||||
91 | } | ||||
92 | | ||||
83 | void initializeLanguages() | 93 | void initializeLanguages() | ||
84 | { | 94 | { | ||
85 | const QByteArray languageCode = getApplicationSpecificLanguage(); | 95 | const QByteArray languageCode = getApplicationSpecificLanguage(); | ||
86 | 96 | | |||
87 | if (!languageCode.isEmpty()) { | 97 | if (!languageCode.isEmpty()) { | ||
88 | QByteArray languages = qgetenv("LANGUAGE"); | 98 | addSetEnvVar("LANGUAGE", languageCode); | ||
89 | if (languages.isEmpty()) { | 99 | addSetEnvVar("LC_ALL", languageCode); | ||
90 | qputenv("LANGUAGE", languageCode); | 100 | // Ideally setting LANGUAGE/LC_ALL would change the default QLocale too | ||
91 | } else { | | |||
92 | qputenv("LANGUAGE", languageCode + ':' + languages); | | |||
93 | } | | |||
94 | // Ideally setting the LANGUAGE would change the default QLocale too | | |||
95 | // but unfortunately this is too late since the QCoreApplication constructor | 101 | // but unfortunately this is too late since the QCoreApplication constructor | ||
96 | // already created a QLocale at this stage so we need to set the reset it | 102 | // already created a QLocale at this stage so we need to set the reset it | ||
97 | // by triggering the creation and destruction of a QSystemLocale | 103 | // by triggering the creation and destruction of a QSystemLocale | ||
98 | // this is highly dependant on Qt internals, so may break, but oh well | 104 | // this is highly dependant on Qt internals, so may break, but oh well | ||
99 | QSystemLocale *dummy = new QSystemLocale(); | 105 | QSystemLocale *dummy = new QSystemLocale(); | ||
100 | delete dummy; | 106 | delete dummy; | ||
101 | } | 107 | } | ||
102 | } | 108 | } | ||
▲ Show 20 Lines • Show All 344 Lines • Show Last 20 Lines |