From 2dc805bcbde0c2351eea6f50f8d25de495d454ec Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Sat, 20 Jul 2024 16:50:44 +0200 Subject: [PATCH] (Linux) Added workaround for a library or OS bug that prevented some locales from working correctly --- es-core/src/utils/LocalizationUtil.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/es-core/src/utils/LocalizationUtil.cpp b/es-core/src/utils/LocalizationUtil.cpp index dd5d07fb2..74b672615 100644 --- a/es-core/src/utils/LocalizationUtil.cpp +++ b/es-core/src/utils/LocalizationUtil.cpp @@ -174,6 +174,12 @@ namespace Utils #else setenv("LANGUAGE", locale.c_str(), 1); setenv("LANG", locale.c_str(), 1); + // For some bizarre reason we need to first set the locale to en_US.UTF-8 before + // we set it to the requested locale as some specific locales like pt_BR and zh_CN + // otherwise won't work consistently. This must be some kind of library or OS bug as + // it only happens on regular Linux, and not on macOS, Windows, Android or FreeBSD. + setlocale(LC_MESSAGES, std::string {"en_US.UTF-8"}.c_str()); + setlocale(LC_MESSAGES, std::string {locale + ".UTF-8"}.c_str()); #endif textdomain(locale.c_str());