diff --git a/CMakeLists.txt b/CMakeLists.txt index 536979b1d..238537f9f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1038,7 +1038,7 @@ elseif(APPLE) src/detection/lm/lm_nosupport.c src/detection/loadavg/loadavg_bsd.c src/detection/libc/libc_apple.c - src/detection/locale/locale_linux.c + src/detection/locale/locale_apple.c src/detection/localip/localip_linux.c src/detection/gamepad/gamepad_apple.c src/detection/media/media_apple.m diff --git a/src/detection/locale/locale_apple.c b/src/detection/locale/locale_apple.c new file mode 100644 index 000000000..c5a5e8e1a --- /dev/null +++ b/src/detection/locale/locale_apple.c @@ -0,0 +1,13 @@ +#include "detection/locale/locale.h" +#include "common/apple/cf_helpers.h" + +const char* ffDetectLocale(FFstrbuf* result) { + // Read the system-wide locale preference (equivalent to `defaults read -g AppleLocale`), + // which is NOT affected by user environment variables (LANG, LC_ALL, etc.) + FF_CFTYPE_AUTO_RELEASE CFStringRef appleLocale = CFPreferencesCopyAppValue(CFSTR("AppleLocale"), kCFPreferencesAnyApplication); + if (!appleLocale) { + return "Failed to read AppleLocale"; + } + + return ffCfStrGetString(appleLocale, result); +}