From 196c617a87d6da42d73912a79f88a41e4dea222a Mon Sep 17 00:00:00 2001 From: Qijia Liu Date: Mon, 20 May 2024 00:32:19 -0400 Subject: [PATCH] Read FCITX_LOCALE env for system locale on macOS --- src/lib/fcitx-utils/i18nstring.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib/fcitx-utils/i18nstring.cpp b/src/lib/fcitx-utils/i18nstring.cpp index 96b844613..2c6f7436a 100644 --- a/src/lib/fcitx-utils/i18nstring.cpp +++ b/src/lib/fcitx-utils/i18nstring.cpp @@ -14,9 +14,10 @@ const std::string &I18NString::match(const std::string &locale_) const { std::string locale = locale_; if (locale == "system") { char *lc = nullptr; - if constexpr (isAndroid()) { + if constexpr (isAndroid() || isApple()) { // bionic doesn't recognize locale other than C or C.UTF-8 // https://android.googlesource.com/platform/bionic/+/refs/tags/android-11.0.0_r48/libc/bionic/locale.cpp#175 + // macOS returns C for setlocale(LC_MESSAGES, nullptr) lc = getenv("FCITX_LOCALE"); } else { lc = setlocale(LC_MESSAGES, nullptr);