Skip to content

Commit

Permalink
fix: the language change in Treeland is not work
Browse files Browse the repository at this point in the history
treeland 下不走 Xsession。手动读取 ~/.config/locale.conf

Log: 修复 treeland 下修改语言不生效
PMS: bug-294913
  • Loading branch information
zsien committed Dec 23, 2024
1 parent 1b262e6 commit 2122d2b
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/dde-session/environmentsmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,23 @@ void EnvironmentsManager::createDBusEnvironments()
for (auto env : additionalEnvs) {
m_envMap.insert(env, qgetenv(env));
}

QByteArray sessionType = qgetenv("XDG_SESSION_TYPE");
if (sessionType == "wayland") {
QFile localeFile(QStandardPaths::locate(QStandardPaths::ConfigLocation, "locale.conf"));
if (localeFile.open(QIODevice::ReadOnly)) {
QTextStream in(&localeFile);

while (!in.atEnd()) {
QString line = in.readLine();
if (line.startsWith("LANG=")) {
m_envMap.insert("LANG", line.mid(strlen("LANG=")));
} else if (line.startsWith("LANGUAGE=")) {
m_envMap.insert("LANGUAGE", line.mid(strlen("LANGUAGE=")));
}
}
}
}
}

bool EnvironmentsManager::unsetEnv(QString env)
Expand Down

0 comments on commit 2122d2b

Please sign in to comment.