File tree Expand file tree Collapse file tree
src/native/libs/System.Globalization.Native Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1616
1717char * DetectDefaultAppleLocaleName (void )
1818{
19- NSLocale *currentLocale = [NSLocale currentLocale ];
20- NSString *localeName = @" " ;
21-
22- if (!currentLocale)
19+ @autoreleasepool
2320 {
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 = @" " ;
2629
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+ }
3543
36- return strdup ([localeName UTF8String ]);
44+ return strdup ([localeName UTF8String ]);
45+ }
46+ }
3747}
3848
3949#if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS)
You can’t perform that action at this time.
0 commit comments