-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[iOS] Retrieve device locale in full (specific) format from ObjectiveC APIs #111032
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -786,21 +786,14 @@ int32_t GlobalizationNative_GetLocalesNative(UChar* value, int32_t length) | |||||
| } | ||||||
| } | ||||||
|
|
||||||
| static NSString* GetBaseName(NSString *localeIdentifier) | ||||||
| { | ||||||
| NSLocale *locale = [[NSLocale alloc] initWithLocaleIdentifier:localeIdentifier]; | ||||||
| NSString *languageCode = [locale objectForKey:NSLocaleLanguageCode]; | ||||||
| return languageCode; | ||||||
| } | ||||||
|
|
||||||
|
Comment on lines
-789
to
-795
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we know what this was done before? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indeed, I was trying this PR to see which test suit breaks if we switch to specific name because there are other dependencies such as Brief history what I found:
I'll try to make a middle way out of this, where we use system locale if it's recognized by .NET, otherwise we use parent culture which is neutral. |
||||||
| const char* GlobalizationNative_GetDefaultLocaleNameNative(void) | ||||||
| { | ||||||
| @autoreleasepool | ||||||
| { | ||||||
| if (NSLocale.preferredLanguages.count > 0) | ||||||
| { | ||||||
| NSString *preferredLanguage = [NSLocale.preferredLanguages objectAtIndex:0]; | ||||||
| return strdup([GetBaseName(preferredLanguage) UTF8String]); | ||||||
| return strdup([preferredLanguage UTF8String]); | ||||||
| } | ||||||
| else | ||||||
| { | ||||||
|
|
@@ -821,7 +814,7 @@ int32_t GlobalizationNative_GetLocalesNative(UChar* value, int32_t length) | |||||
| localeName = currentLocale.localeIdentifier; | ||||||
| } | ||||||
|
|
||||||
| return strdup([GetBaseName(localeName) UTF8String]); | ||||||
| return strdup([localeName UTF8String]); | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
Uh oh!
There was an error while loading. Please reload this page.