Skip to content
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

Fix neutral cultures created with the underscore #87411

Merged
merged 2 commits into from
Jun 13, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -463,6 +463,8 @@ public void TestNeutralCultureWithCollationName()
[InlineData("xx-u-XX-u-yy", "xx-u-xx-u-yy")]
[InlineData("xx-t-ja-JP", "xx-t-ja-jp")]
[InlineData("qps-plocm", "qps-PLOCM")] // ICU normalize this name to "qps--plocm" which we normalize it back to "qps-plocm"
[InlineData("zh_CN", "zh_cn")]
[InlineData("km_KH", "km_kh")]
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsIcuGlobalization))]
public void TestCreationWithICUNormalizedNames(string cultureName, string expectedCultureName)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,9 @@ private bool InitIcuCultureDataCore()
_bNeutral = TwoLetterISOCountryName.Length == 0;
_sSpecificCulture = _bNeutral ? IcuLocaleData.GetSpecificCultureName(_sRealName) : _sRealName;

if (_bNeutral && collationStart > 0)
{
return false; // neutral cultures cannot have collation
}

// Remove the sort from sName unless custom culture
_sName = collationStart < 0 ? _sRealName : _sRealName.Substring(0, collationStart);
// To ensure compatibility, it is necessary to allow the creation of cultures like zh_CN (using ICU notation) in the case of _bNeutral.
_sName = collationStart < 0 || _bNeutral ? _sRealName : _sRealName.Substring(0, collationStart);

return true;
}
Expand Down