Blender  V3.3
osx_user_locale.mm
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2012 Blender Foundation. All rights reserved. */
3 
4 #include "boost_locale_wrapper.h"
5 
10 #import <Cocoa/Cocoa.h>
11 
12 #include <cstdlib>
13 
14 static char *user_locale = NULL;
15 
16 // get current locale
17 const char *osx_user_locale()
18 {
20  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
21  CFLocaleRef myCFLocale = CFLocaleCopyCurrent();
22  NSLocale *myNSLocale = (NSLocale *)myCFLocale;
23  [myNSLocale autorelease];
24 
25  // This produces gettext-invalid locale in recent macOS versions (11.4),
26  // like `ko-Kore_KR` instead of `ko_KR`. See T88877.
27  // NSString *nsIdentifier = [myNSLocale localeIdentifier];
28 
29  const NSString *nsIdentifier = [myNSLocale languageCode];
30  const NSString *const nsIdentifier_country = [myNSLocale countryCode];
31  if ([nsIdentifier length] != 0 && [nsIdentifier_country length] != 0) {
32  nsIdentifier = [NSString stringWithFormat:@"%@_%@", nsIdentifier, nsIdentifier_country];
33  }
34 
35  user_locale = ::strdup([nsIdentifier UTF8String]);
36  [pool drain];
37 
38  return user_locale;
39 }
void BLI_kdtree_nd_() free(KDTree *tree)
Definition: kdtree_impl.h:102
T length(const vec_base< T, Size > &a)
static char * user_locale
const char * osx_user_locale()