diff --git a/src/modules/clock.cpp b/src/modules/clock.cpp index c4c460cc..5fda73f2 100644 --- a/src/modules/clock.cpp +++ b/src/modules/clock.cpp @@ -66,17 +66,12 @@ waybar::modules::Clock::Clock(const std::string& id, const Json::Value& config) } } - if (config_["locale"].isString()) { - locale_ = std::locale(config_["locale"].asString()); - } else { - char* sysLocale{getenv("LC_TIME")}; - try { - locale_ = sysLocale ? std::locale(sysLocale) : std::locale(""); - } - catch(std::runtime_error const& localeErr) { - spdlog::warn(localeErr.what()); - locale_ = std::locale(); - } + const char* applyLocale{config_["locale"].isString() ? config_["locale"].asCString() : getenv("LC_TIME")}; + try { + locale_ = applyLocale ? std::locale(applyLocale) : std::locale(""); + } catch(std::runtime_error const& localeE) { + 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_ = std::locale(); } thread_ = [this] {