File tree 1 file changed +25
-15
lines changed
src/native/libs/System.Globalization.Native
1 file changed +25
-15
lines changed Original file line number Diff line number Diff line change 16
16
17
17
char * DetectDefaultAppleLocaleName (void )
18
18
{
19
- NSLocale *currentLocale = [NSLocale currentLocale ];
20
- NSString *localeName = @" " ;
21
-
22
- if (!currentLocale)
19
+ @autoreleasepool
23
20
{
24
- return strdup ([localeName UTF8String ]);
25
- }
21
+ if (NSLocale .preferredLanguages .count > 0 )
22
+ {
23
+ return strdup ([NSLocale .preferredLanguages[0 ] UTF8String ]);
24
+ }
25
+ else
26
+ {
27
+ NSLocale *currentLocale = [NSLocale currentLocale ];
28
+ NSString *localeName = @" " ;
26
29
27
- if ([currentLocale.languageCode length ] > 0 && [currentLocale.countryCode length ] > 0 )
28
- {
29
- localeName = [NSString stringWithFormat: @" %@ -%@ " , currentLocale.languageCode, currentLocale.countryCode];
30
- }
31
- else
32
- {
33
- localeName = currentLocale.localeIdentifier ;
34
- }
30
+ if (!currentLocale)
31
+ {
32
+ return strdup ([localeName UTF8String ]);
33
+ }
34
+
35
+ if ([currentLocale.languageCode length ] > 0 && [currentLocale.countryCode length ] > 0 )
36
+ {
37
+ localeName = [NSString stringWithFormat: @" %@ -%@ " , currentLocale.languageCode, currentLocale.countryCode];
38
+ }
39
+ else
40
+ {
41
+ localeName = currentLocale.localeIdentifier ;
42
+ }
35
43
36
- return strdup ([localeName UTF8String ]);
44
+ return strdup ([localeName UTF8String ]);
45
+ }
46
+ }
37
47
}
38
48
39
49
#if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS)
You can’t perform that action at this time.
0 commit comments