Skip to content

Commit 2122d2b

Browse files
committed
fix: the language change in Treeland is not work
treeland 下不走 Xsession。手动读取 ~/.config/locale.conf Log: 修复 treeland 下修改语言不生效 PMS: bug-294913
1 parent 1b262e6 commit 2122d2b

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/dde-session/environmentsmanager.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,23 @@ void EnvironmentsManager::createDBusEnvironments()
120120
for (auto env : additionalEnvs) {
121121
m_envMap.insert(env, qgetenv(env));
122122
}
123+
124+
QByteArray sessionType = qgetenv("XDG_SESSION_TYPE");
125+
if (sessionType == "wayland") {
126+
QFile localeFile(QStandardPaths::locate(QStandardPaths::ConfigLocation, "locale.conf"));
127+
if (localeFile.open(QIODevice::ReadOnly)) {
128+
QTextStream in(&localeFile);
129+
130+
while (!in.atEnd()) {
131+
QString line = in.readLine();
132+
if (line.startsWith("LANG=")) {
133+
m_envMap.insert("LANG", line.mid(strlen("LANG=")));
134+
} else if (line.startsWith("LANGUAGE=")) {
135+
m_envMap.insert("LANGUAGE", line.mid(strlen("LANGUAGE=")));
136+
}
137+
}
138+
}
139+
}
123140
}
124141

125142
bool EnvironmentsManager::unsetEnv(QString env)

0 commit comments

Comments
 (0)