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 @@ -8,15 +8,18 @@ namespace System.Globalization.Tests
{
public class CultureInfoEnglishName
{
// Android has its own ICU, which doesn't 100% map to UsingLimitedCultures
public static bool SupportFullGlobalizationData => PlatformDetection.IsNotUsingLimitedCultures || PlatformDetection.IsAndroid;

public static IEnumerable<object[]> EnglishName_TestData()
{
yield return new object[] { CultureInfo.CurrentCulture.Name, CultureInfo.CurrentCulture.EnglishName };

// Android has its own ICU, which doesn't 100% map to UsingLimitedCultures
if (PlatformDetection.IsNotUsingLimitedCultures || PlatformDetection.IsAndroid)
if (SupportFullGlobalizationData)
{
yield return new object[] { "en-US", "English (United States)" };
yield return new object[] { "fr-FR", "French (France)" };
yield return new object[] { "uz-Cyrl", "Uzbek (Cyrillic)" };
}
else
{
Expand All @@ -33,5 +36,17 @@ public void EnglishName(string name, string expected)
CultureInfo myTestCulture = new CultureInfo(name);
Assert.Equal(expected, myTestCulture.EnglishName);
}

[ConditionalFact(nameof(SupportFullGlobalizationData))]
public void ChineseNeutralEnglishName()
{
CultureInfo ci = new CultureInfo("zh-Hans");
Assert.True(ci.EnglishName == "Chinese (Simplified)" || ci.EnglishName == "Chinese, Simplified",
$"'{ci.EnglishName}' not equal to `Chinese (Simplified)` nor `Chinese, Simplified`");

ci = new CultureInfo("zh-HanT");
Assert.True(ci.EnglishName == "Chinese (Traditional)" || ci.EnglishName == "Chinese, Traditional",
$"'{ci.EnglishName}' not equal to `Chinese (Traditional)` nor `Chinese, Traditional`");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -969,7 +969,12 @@ internal string EnglishName
// If its neutral use the language name
if (IsNeutralCulture)
{
englishDisplayName = EnglishLanguageName;
englishDisplayName = GetLocaleInfoCore(LocaleStringData.EnglishDisplayName);
if (string.IsNullOrEmpty(englishDisplayName))
{
englishDisplayName = EnglishLanguageName;
}

// differentiate the legacy display names
switch (_sName)
{
Expand Down Expand Up @@ -1026,7 +1031,12 @@ internal string NativeName
// If its neutral use the language name
if (IsNeutralCulture)
{
nativeDisplayName = NativeLanguageName;
nativeDisplayName = GetLocaleInfoCore(LocaleStringData.NativeDisplayName);
if (string.IsNullOrEmpty(nativeDisplayName))
{
nativeDisplayName = NativeLanguageName;
}

// differentiate the legacy display names
switch (_sName)
{
Expand Down