From 0486fe3e7db528c98c90ef8e4624aff5019fa385 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Fri, 1 May 2020 12:32:38 -0600 Subject: set LC_ALL from macOS locale so that setlocale(2) will work --- gtk2_ardour/cocoacarbon.mm | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'gtk2_ardour') diff --git a/gtk2_ardour/cocoacarbon.mm b/gtk2_ardour/cocoacarbon.mm index 1d1dd86adf..6d646c763e 100644 --- a/gtk2_ardour/cocoacarbon.mm +++ b/gtk2_ardour/cocoacarbon.mm @@ -122,16 +122,19 @@ set_language_preference () } } - /* now get AppleLocale value and use that for LANG */ + /* now get AppleLocale value and use that to set LC_ALL because Launchd-started processes (i.e. GUI apps) + do not have this environment variable set, and without it, setlocale (LC_ALL, "") will fail. + + Note that it doesn't matter much what we set LC_ALL to for gettext's purposes, but other aspects of the + locale system do need a value that mostly/sort-of/kind-of represents the user's own preferences. So, get + that from CoreFoundation APIs. + */ CFLocaleRef cflocale = CFLocaleCopyCurrent(); NSString* nslocale = (NSString*) CFLocaleGetValue (cflocale, kCFLocaleIdentifier); - /* the full POSIX locale specification allows for lots of things. that could be an issue. Silly Apple. - */ - - cout << "LANG set to " << [nslocale UTF8String] << endl; - setenv ("LANG", [nslocale UTF8String], 0); + cout << "Apple's CoreFoundation API says that this user's locale is " << [nslocale UTF8String] << endl; + setenv ("LC_ALL", [nslocale UTF8String], 0); CFRelease (cflocale); } -- cgit v1.2.3