Blender  V2.93
osx_user_locale.mm
Go to the documentation of this file.
1 #include "boost_locale_wrapper.h"
2 
3 #import <Cocoa/Cocoa.h>
4 
5 #include <cstdlib>
6 
7 static char *user_locale = NULL;
8 
9 // get current locale
10 const char *osx_user_locale()
11 {
13  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
14  CFLocaleRef myCFLocale = CFLocaleCopyCurrent();
15  NSLocale *myNSLocale = (NSLocale *)myCFLocale;
16  [myNSLocale autorelease];
17 
18  // This produces gettext-invalid locale in recent macOS versions (11.4),
19  // like `ko-Kore_KR` instead of `ko_KR`. See T88877.
20  // NSString *nsIdentifier = [myNSLocale localeIdentifier];
21 
22  const NSString *nsIdentifier = [myNSLocale languageCode];
23  const NSString *const nsIdentifier_country = [myNSLocale countryCode];
24  if ([nsIdentifier length] != 0 && [nsIdentifier_country length] != 0) {
25  nsIdentifier = [NSString stringWithFormat:@"%@_%@", nsIdentifier, nsIdentifier_country];
26  }
27 
28  user_locale = ::strdup([nsIdentifier UTF8String]);
29  [pool drain];
30 
31  return user_locale;
32 }
void BLI_kdtree_nd_() free(KDTree *tree)
Definition: kdtree_impl.h:116
SIMD_FORCE_INLINE btScalar length(const btQuaternion &q)
Return the length of a quaternion.
Definition: btQuaternion.h:895
static char * user_locale
const char * osx_user_locale()