Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ public void CurrentCulture_Default_Not_Invariant()
Assert.NotEqual(CultureInfo.CurrentUICulture, CultureInfo.InvariantCulture);
}

[Fact]
[PlatformSpecific(TestPlatforms.OSX | TestPlatforms.iOS | TestPlatforms.MacCatalyst | TestPlatforms.tvOS)]
[SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.MacCatalyst | TestPlatforms.tvOS, "https://github.com/dotnet/runtime/issues/111501")]
public void CurrentCulture_Default_Is_Specific()
{
// On OSX-like platforms, the current culture taken from default system culture should be specific.
Assert.False(CultureInfo.CurrentCulture.IsNeutralCulture);
}

[Fact]
public void CurrentCulture_Set_Null_ThrowsArgumentNullException()
{
Expand Down
11 changes: 2 additions & 9 deletions src/native/libs/System.Globalization.Native/pal_locale.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

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
{
Expand All @@ -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]);
}
}
}
Expand Down
Loading