Issue#1552. Calendar module, LC_TIME variable

pull/1553/head
Viktar Lukashonak 2022-05-13 12:54:18 +03:00
parent 7b7ee41e13
commit 448b413eca
No known key found for this signature in database
GPG Key ID: 08A413AA87200A6F
1 changed files with 6 additions and 11 deletions

View File

@ -66,17 +66,12 @@ waybar::modules::Clock::Clock(const std::string& id, const Json::Value& config)
} }
} }
if (config_["locale"].isString()) { const char* applyLocale{config_["locale"].isString() ? config_["locale"].asCString() : getenv("LC_TIME")};
locale_ = std::locale(config_["locale"].asString()); try {
} else { locale_ = applyLocale ? std::locale(applyLocale) : std::locale("");
char* sysLocale{getenv("LC_TIME")}; } catch(std::runtime_error const& localeE) {
try { spdlog::warn("Clock module. Wrong \"locale\" or LC_TIME variable(make sure locale is presented in /etc/locale.gen and generated by the locale-gen). Trace: {0}", localeE.what());
locale_ = sysLocale ? std::locale(sysLocale) : std::locale(""); locale_ = std::locale();
}
catch(std::runtime_error const& localeErr) {
spdlog::warn(localeErr.what());
locale_ = std::locale();
}
} }
thread_ = [this] { thread_ = [this] {