Skip to content

Commit b3ee47d

Browse files
authored
[ios][HybridGlobalization] Fix default culture (#104071)
Update default locale name only return base name
1 parent c21a1f6 commit b3ee47d

File tree

5 files changed

+11
-16
lines changed

5 files changed

+11
-16
lines changed

src/libraries/System.Data.Common/tests/System/Data/SqlTypes/SqlDecimalTest.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,6 @@ public void AdjustScale()
196196
}
197197

198198
[Fact]
199-
[ActiveIssue("https://github.com/dotnet/runtime/issues/95195", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnApplePlatform))]
200199
public void ConvertToPrecScale()
201200
{
202201
Assert.Equal(new SqlDecimal(6464.6m).Value, SqlDecimal.ConvertToPrecScale(_test1, 5, 1).Value);

src/libraries/System.Data.Common/tests/System/Data/SqlTypes/SqlStringSortingTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public static class SqlStringSortingTest
3838
private static readonly UnicodeEncoding s_unicodeEncoding = new UnicodeEncoding(bigEndian: false, byteOrderMark: false, throwOnInvalidBytes: true);
3939

4040
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))]
41-
[ActiveIssue("https://github.com/dotnet/runtime/issues/95195", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnApplePlatform))]
41+
[ActiveIssue("https://github.com/dotnet/runtime/issues/95338", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnApplePlatform))]
4242
[InlineData("ja-JP", 0x0411)] // Japanese - Japan
4343
[InlineData("ar-SA", 0x0401)] // Arabic - Saudi Arabia
4444
[InlineData("de-DE", 0x0407)] // German - Germany

src/libraries/System.Data.Common/tests/System/Data/SqlTypes/SqlStringTest.cs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ public SqlStringTest()
5656
}
5757

5858
[Fact]
59-
[ActiveIssue("https://github.com/dotnet/runtime/issues/95195", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnApplePlatform))]
6059
public void Constructor_Value_Success()
6160
{
6261
const string value = "foo";
@@ -220,7 +219,6 @@ public void CompareToSqlTypeException()
220219
}
221220

222221
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))]
223-
[ActiveIssue("https://github.com/dotnet/runtime/issues/95195", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnApplePlatform))]
224222
public void CompareTo()
225223
{
226224
Assert.True(_test1.CompareTo(_test3) < 0);
@@ -261,7 +259,6 @@ public void CompareTo()
261259
}
262260

263261
[Fact]
264-
[ActiveIssue("https://github.com/dotnet/runtime/issues/95195", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnApplePlatform))]
265262
public void EqualsMethods()
266263
{
267264
Assert.False(_test1.Equals(_test2));
@@ -278,7 +275,6 @@ public void EqualsMethods()
278275
}
279276

280277
[Fact]
281-
[ActiveIssue("https://github.com/dotnet/runtime/issues/95195", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnApplePlatform))]
282278
public void Greaters()
283279
{
284280
// GreateThan ()
@@ -293,7 +289,6 @@ public void Greaters()
293289
}
294290

295291
[Fact]
296-
[ActiveIssue("https://github.com/dotnet/runtime/issues/95195", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnApplePlatform))]
297292
public void Lessers()
298293
{
299294
// LessThan()
@@ -309,7 +304,6 @@ public void Lessers()
309304
}
310305

311306
[Fact]
312-
[ActiveIssue("https://github.com/dotnet/runtime/issues/95195", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnApplePlatform))]
313307
public void NotEquals()
314308
{
315309
Assert.True(SqlString.NotEquals(_test1, _test2).Value);
@@ -320,7 +314,6 @@ public void NotEquals()
320314
}
321315

322316
[Fact]
323-
[ActiveIssue("https://github.com/dotnet/runtime/issues/95195", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnApplePlatform))]
324317
public void Concat()
325318
{
326319
_test1 = new SqlString("First TestString");
@@ -332,7 +325,6 @@ public void Concat()
332325
}
333326

334327
[Fact]
335-
[ActiveIssue("https://github.com/dotnet/runtime/issues/95195", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnApplePlatform))]
336328
public void Clone()
337329
{
338330
SqlString testSqlString = _test1.Clone();
@@ -352,7 +344,6 @@ public void CompareOptionsFromSqlCompareOptions()
352344
}
353345

354346
[Fact]
355-
[ActiveIssue("https://github.com/dotnet/runtime/issues/95195", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnApplePlatform))]
356347
public void UnicodeBytes()
357348
{
358349
Assert.Equal((byte)105, _test1.GetNonUnicodeBytes()[1]);
@@ -549,7 +540,6 @@ public void Conversions()
549540
// OPERATORS
550541

551542
[Fact]
552-
[ActiveIssue("https://github.com/dotnet/runtime/issues/95195", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnApplePlatform))]
553543
public void ArithmeticOperators()
554544
{
555545
SqlString testString = new SqlString("...Testing...");
@@ -558,7 +548,6 @@ public void ArithmeticOperators()
558548
}
559549

560550
[Fact]
561-
[ActiveIssue("https://github.com/dotnet/runtime/issues/95195", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnApplePlatform))]
562551
public void ThanOrEqualOperators()
563552
{
564553
// == -operator

src/libraries/System.Runtime/tests/System.Reflection.Tests/AssemblyNameTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,6 @@ public void CultureName_Set(AssemblyName assemblyName, string originalCultureNam
222222
}
223223

224224
[Fact]
225-
[ActiveIssue("https://github.com/dotnet/runtime/issues/95195", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnApplePlatform))]
226225
public void CultureName_Set_Invalid_ThrowsCultureNotFoundException()
227226
{
228227
var assemblyName = new AssemblyName("Test");

src/native/libs/System.Globalization.Native/pal_locale.m

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -786,13 +786,21 @@ int32_t GlobalizationNative_GetLocalesNative(UChar* value, int32_t length)
786786
}
787787
}
788788

789+
static NSString* GetBaseName(NSString *localeIdentifier)
790+
{
791+
NSLocale *locale = [[NSLocale alloc] initWithLocaleIdentifier:localeIdentifier];
792+
NSString *languageCode = [locale objectForKey:NSLocaleLanguageCode];
793+
return languageCode;
794+
}
795+
789796
const char* GlobalizationNative_GetDefaultLocaleNameNative(void)
790797
{
791798
@autoreleasepool
792799
{
793800
if (NSLocale.preferredLanguages.count > 0)
794801
{
795-
return strdup([NSLocale.preferredLanguages[0] UTF8String]);
802+
NSString *preferredLanguage = [NSLocale.preferredLanguages objectAtIndex:0];
803+
return strdup([GetBaseName(preferredLanguage) UTF8String]);
796804
}
797805
else
798806
{
@@ -813,7 +821,7 @@ int32_t GlobalizationNative_GetLocalesNative(UChar* value, int32_t length)
813821
localeName = currentLocale.localeIdentifier;
814822
}
815823

816-
return strdup([localeName UTF8String]);
824+
return strdup([GetBaseName(localeName) UTF8String]);
817825
}
818826
}
819827
}

0 commit comments

Comments
 (0)