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

[browser][non-icu] HybridGlobalization locales covering LocaleStringData. #87972

Closed
wants to merge 6 commits into from
Closed
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
64 changes: 64 additions & 0 deletions docs/design/features/globalization-hybrid-mode.md
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,70 @@ Using `IgnoreNonSpace` for these two with `HybridGlobalization` off, also return
new CultureInfo("de-DE").CompareInfo.IndexOf("strasse", "stra\u00DFe", 0, CompareOptions.IgnoreNonSpace); // 0 or -1
```

**CultureInfo**

Affected public APIs:
- DisplayName
- EnglishName
- NativeName

DisplayName, EnglishName and NativeName use []`Intl.DisplayNames`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames) with `{type: "language"}`, so some values can slightly differ, see on the example of `NativeName` (`DisplayName` and `EnglishName` differ accordingly):

| **locale** | **Non-Hybrid** | **Hybrid** |
|:----------:|:---------------------------------:|:-------------------------------------:|
| **de-AT** | Deutsch (Österreich) | Österreichisches Deutsch |
| **de-CH** | Deutsch (Schweiz) | Schweizer Hochdeutsch |
| **en-AU** | English (Australia) | Australian English |
| **en-CA** | Australian English | Canadian English |
| **en-GB** | English (United Kingdom) | British English |
| **en-VC** | English (St Vincent & Grenadines) | English (St Vincent & the Grenadines) |
| **en-US** | English (United States) | American English |
| **es-419** | español (Latinoamérica) | español latinoamericano |
| **es-ES** | español (España) | español de España |
| **es-MX** | español (México) | español de México |
| **fr-CA** | français (Canada) | français canadien |
| **fr-CH** | français (Suisse) | français suisse |
| **nl-BE** | Nederlands (België) | Vlaams |
| **pt-PT** | português (Portugal) | português europeu |
| **zh-SG** | 中文(简体,中国香港特别行政区) | 简体中文(中国香港特别行政区) |


**NumberFormatInfo**
CurrencyDecimalDigits (Int: ToDo in the follow-up PR)
- CurrencyDecimalSeparator
- CurrencyGroupSeparator
CurrencyGroupSizes (Int[]: ToDo in the follow-up PR)
CurrencyNegativePattern (Int: ToDo in the follow-up PR)
CurrencyPositivePattern (Int: ToDo in the follow-up PR)
- CurrencySymbol
- NaNSymbol
- NativeDigits
NegativeInfinitySymbol (Calendars: ToDo in the follow-up PR)
- NegativeSign
NumberDecimalDigits (Int: ToDo in the follow-up PR)
- NumberDecimalSeparator
- NumberGroupSeparator
NumberGroupSizes (Int[]: ToDo in the follow-up PR)
NumberNegativePattern (Int: ToDo in the follow-up PR)
PercentDecimalDigits (Int: ToDo in the follow-up PR)
- PercentDecimalSeparator
- PercentGroupSeparator
PercentGroupSizes (Int[]: ToDo in the follow-up PR)
PercentNegativePattern (Int: ToDo in the follow-up PR)
PercentPositivePattern (Int: ToDo in the follow-up PR)
- PercentSymbol
- PerMilleSymbol
PositiveInfinitySymbol (Calendars: ToDo in the follow-up PR)
- PositiveSign

`CurrencySymbol` uses [`toLocaleString`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleString) with `{ style: "currency" }` that restuls in following differences:
| **locale** | **Non-Hybrid** | **Hybrid** |
|:----------:|:---------------------------------:|:-------------------------------------:|
| **en-SL** | Le | SLL |
| **hr-HR** | HRK | kn |

**TextInfo**
IsRightToLeft (Int: ToDo in the following PR)

### OSX

Expand Down
31 changes: 31 additions & 0 deletions src/libraries/Common/src/Interop/Browser/Interop.Locale.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Runtime.CompilerServices;

internal static partial class Interop
{
internal static unsafe partial class JsGlobalization
{
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal static extern unsafe int JsGetMonetarySymbol(in string culture, in string isoSymbol, char* buffer, int bufferLength, out int exceptionalResult, out object result);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal static extern unsafe int JsGetMonetaryDecimalSeparator(in string culture, in string isoSymbol, char* buffer, int bufferLength, out int exceptionalResult, out object result);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal static extern unsafe int JsGetDecimalSeparator(in string culture, char* buffer, int bufferLength, out int exceptionalResult, out object result);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal static extern unsafe int JsGetMonetaryThousandSeparator(in string culture, in string isoSymbol, char* buffer, int bufferLength, out int exceptionalResult, out object result);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal static extern unsafe int JsGetThousandSeparator(in string culture, char* buffer, int bufferLength, out int exceptionalResult, out object result);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal static extern unsafe int JsGetDigits(in string culture, char* buffer, int bufferLength, out int exceptionalResult, out object result);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal static extern unsafe int JsGeCurrencyName(in string culture, in string isoSymbol, char* buffer, int bufferLength, out int exceptionalResult, out object result);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal static extern unsafe int JsGetCountryName(in string culture, in string region, char* buffer, int bufferLength, out int exceptionalResult, out object result);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal static extern unsafe int JsGetLanguageName(in string culture, in string region, char* buffer, int bufferLength, out int exceptionalResult, out object result);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal static extern unsafe int JsGetDisplayName(in string culture, in string displayCulture, char* buffer, int bufferLength, out int exceptionalResult, out object result);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ public static IEnumerable<object[]> EnglishName_TestData()
yield return new object[] { "fr-FR", "French (France)" };
yield return new object[] { "uz-Cyrl", "Uzbek (Cyrillic)" };
}
else if (PlatformDetection.IsHybridGlobalizationOnBrowser)
{
yield return new object[] { "bn-BD", "Bangla (Bangladesh)" };
yield return new object[] { "en-CC", "English (Cocos [Keeling] Islands)" };
yield return new object[] { "en-MP", "English (Northern Mariana Islands)" };
yield return new object[] { "en-US", "American English" };
yield return new object[] { "fr-FR", "French (France)" };
yield return new object[] { "hr-BA", "Croatian (Bosnia & Herzegovina)" };
}
else
{
// Mobile / Browser ICU doesn't contain CultureInfo.EnglishName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,21 @@ public static IEnumerable<object[]> NativeName_TestData()
yield return new object[] { "en-US", "English (United States)" };
yield return new object[] { "en-CA", "English (Canada)" };
}
else if (PlatformDetection.IsHybridGlobalizationOnBrowser)
{
yield return new object[] { "ar-SA", "\u0627\u0644\u0639\u0631\u0628\u064a\u0629\u0020\u0028\u0627\u0644\u0645\u0645\u0644\u0643\u0629\u0020\u0627\u0644\u0639\u0631\u0628\u064a\u0629\u0020\u0627\u0644\u0633\u0639\u0648\u062f\u064a\u0629\u0029" };
yield return new object[] { "de-BE", "Deutsch (Belgien)" };
yield return new object[] { "de-DE", "Deutsch (Deutschland)" };
yield return new object[] { "en-CA", "Canadian English" };
yield return new object[] { "en-US", "American English" };
yield return new object[] { "nb-NO", "norsk bokm\u00e5l (Norge)" };
yield return new object[] { "no", "norsk" };
yield return new object[] { "no-NO", "norsk (Norge)" };
yield return new object[] { "sr-Cyrl-RS", "\u0441\u0440\u043f\u0441\u043a\u0438\u0020\u0028\u045b\u0438\u0440\u0438\u043b\u0438\u0446\u0430\u002c\u0020\u0421\u0440\u0431\u0438\u0458\u0430\u0029" };
yield return new object[] { "sr-Latn-RS", "srpski (latinica, Srbija)" };
yield return new object[] { "sw-CD", "Kiswahili (Jamhuri ya Kidemokrasia ya Kongo)" };
yield return new object[] { "zh-TW", "\u4e2d\u6587\uff08\u53f0\u7063\uff09" };
}
else
{
// Mobile / Browser ICU doesn't contain CultureInfo.NativeName
Expand Down
Loading