diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2020-05-01 12:32:38 -0600 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2020-05-01 12:32:38 -0600 |
commit | 0486fe3e7db528c98c90ef8e4624aff5019fa385 (patch) | |
tree | 4c43f725a450e0725c596064df78c07001fd847a /gtk2_ardour | |
parent | 6479a1c9d506a30dbf880e03555868a9dd50dc6d (diff) |
set LC_ALL from macOS locale so that setlocale(2) will work
Diffstat (limited to 'gtk2_ardour')
-rw-r--r-- | gtk2_ardour/cocoacarbon.mm | 15 |
1 files changed, 9 insertions, 6 deletions
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); } |