Blender V4.3
osx_user_locale.mm
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2012 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
6
11#import <Cocoa/Cocoa.h>
12
13#include <cstdlib>
14
15static char *user_locale = nullptr;
16
17/* Get current locale. */
18const char *osx_user_locale()
19{
21
22 @autoreleasepool {
23 CFLocaleRef myCFLocale = CFLocaleCopyCurrent();
24 NSLocale *myNSLocale = (NSLocale *)myCFLocale;
25 [myNSLocale autorelease];
26
27 /* This produces gettext-invalid locale in recent macOS versions (11.4),
28 * like `ko-Kore_KR` instead of `ko_KR`. See #88877. */
29 // NSString *nsIdentifier = [myNSLocale localeIdentifier];
30
31 NSString *nsIdentifier = myNSLocale.languageCode;
32 NSString *nsIdentifier_country = myNSLocale.countryCode;
33 if (nsIdentifier.length != 0 && nsIdentifier_country.length != 0) {
34 nsIdentifier = [NSString stringWithFormat:@"%@_%@", nsIdentifier, nsIdentifier_country];
35 }
36
37 user_locale = ::strdup(nsIdentifier.UTF8String);
38 }
39
40 return user_locale;
41}
void BLI_kdtree_nd_ free(KDTree *tree)
static char * user_locale
const char * osx_user_locale()