diff options
author | Bastien Montagne <bastien@blender.org> | 2021-10-29 11:24:37 +0300 |
---|---|---|
committer | Bastien Montagne <bastien@blender.org> | 2021-10-29 11:24:37 +0300 |
commit | fb688c8d5c431708218d342552c5fb0806c97f2d (patch) | |
tree | e5d1ca40690822eb33014660340a169ffb0c259d | |
parent | 261bb766fbaf701baafed25f1ae5ea38d5e52151 (diff) | |
parent | be0d5da341cf3f33ba2d7cca8c979abf9d94f683 (diff) |
Merge branch 'blender-v3.0-release'
-rw-r--r-- | intern/locale/boost_locale_wrapper.cpp | 7 | ||||
-rw-r--r-- | intern/locale/osx_user_locale.mm | 12 |
2 files changed, 18 insertions, 1 deletions
diff --git a/intern/locale/boost_locale_wrapper.cpp b/intern/locale/boost_locale_wrapper.cpp index 73433fe7c5e..ede9377b38f 100644 --- a/intern/locale/boost_locale_wrapper.cpp +++ b/intern/locale/boost_locale_wrapper.cpp @@ -117,6 +117,13 @@ void bl_locale_set(const char *locale) #undef LOCALE_INFO } + // Extra catch on `std::runtime_error` is needed for macOS/Clang as it seems that exceptions + // like `boost::locale::conv::conversion_error` (which inherit from `std::runtime_error`) are + // not caught by their ancestor `std::exception`. See + // https://developer.blender.org/T88877#1177108 . + catch (std::runtime_error const &e) { + std::cout << "bl_locale_set(" << locale << "): " << e.what() << " \n"; + } catch (std::exception const &e) { std::cout << "bl_locale_set(" << locale << "): " << e.what() << " \n"; } diff --git a/intern/locale/osx_user_locale.mm b/intern/locale/osx_user_locale.mm index e2f65d39df9..ce694b5fc1e 100644 --- a/intern/locale/osx_user_locale.mm +++ b/intern/locale/osx_user_locale.mm @@ -14,7 +14,17 @@ const char *osx_user_locale() CFLocaleRef myCFLocale = CFLocaleCopyCurrent(); NSLocale *myNSLocale = (NSLocale *)myCFLocale; [myNSLocale autorelease]; - NSString *nsIdentifier = [myNSLocale localeIdentifier]; + + // This produces gettext-invalid locale in recent macOS versions (11.4), + // like `ko-Kore_KR` instead of `ko_KR`. See T88877. + // NSString *nsIdentifier = [myNSLocale localeIdentifier]; + + const NSString *nsIdentifier = [myNSLocale languageCode]; + const NSString *const nsIdentifier_country = [myNSLocale countryCode]; + if ([nsIdentifier length] != 0 && [nsIdentifier_country length] != 0) { + nsIdentifier = [NSString stringWithFormat:@"%@_%@", nsIdentifier, nsIdentifier_country]; + } + user_locale = ::strdup([nsIdentifier UTF8String]); [pool drain]; |