From babf10ea2a97bcee916f13b5faad4b8768698dcc Mon Sep 17 00:00:00 2001 From: Mark Gross Date: Wed, 3 Jul 2024 09:21:22 -0700 Subject: [PATCH] Change th-TH culture to th Web browsers (at least Firefox and Chromium) only send th in the Accept-Language header, leading ASP.NET to select it as the current culture. This leads to Humanizer failing to find the resource and consequently falling back to the default culture. Renaming the resource files to the more generic culture specifier fixes the issue. --- ...er.Core.th-TH.nuspec => Humanizer.Core.th.nuspec} | 12 ++++++------ NuSpecs/Humanizer.nuspec | 2 +- .../Localisation/{th-TH => th}/DateHumanizeTests.cs | 4 ++-- .../Localisation/{th-TH => th}/NumberToWordsTests.cs | 4 ++-- src/Humanizer/Configuration/FormatterRegistry.cs | 4 ++-- .../Configuration/NumberToWordsConverterRegistry.cs | 4 ++-- .../{Resources.th-TH.resx => Resources.th.resx} | 0 7 files changed, 15 insertions(+), 15 deletions(-) rename NuSpecs/{Humanizer.Core.th-TH.nuspec => Humanizer.Core.th.nuspec} (68%) rename src/Humanizer.Tests/Localisation/{th-TH => th}/DateHumanizeTests.cs (91%) rename src/Humanizer.Tests/Localisation/{th-TH => th}/NumberToWordsTests.cs (98%) rename src/Humanizer/Properties/{Resources.th-TH.resx => Resources.th.resx} (100%) diff --git a/NuSpecs/Humanizer.Core.th-TH.nuspec b/NuSpecs/Humanizer.Core.th.nuspec similarity index 68% rename from NuSpecs/Humanizer.Core.th-TH.nuspec rename to NuSpecs/Humanizer.Core.th.nuspec index f4c70d3b9..1b3bbb99f 100644 --- a/NuSpecs/Humanizer.Core.th-TH.nuspec +++ b/NuSpecs/Humanizer.Core.th.nuspec @@ -1,23 +1,23 @@  - Humanizer.Core.th-TH + Humanizer.Core.th $version$ - Humanizer Locale (th-TH) + Humanizer Locale (th) Mehdi Khalili, Claire Novotny https://github.com/Humanizr/Humanizer logo.png false - Humanizer Locale Thai (Thailand) (th-TH) + Humanizer Locale Thai (th) Copyright (c) .NET Foundation and Contributors MIT - th-TH + th - + - \ No newline at end of file + diff --git a/NuSpecs/Humanizer.nuspec b/NuSpecs/Humanizer.nuspec index 9079ae408..4699bf36f 100644 --- a/NuSpecs/Humanizer.nuspec +++ b/NuSpecs/Humanizer.nuspec @@ -56,7 +56,7 @@ - + diff --git a/src/Humanizer.Tests/Localisation/th-TH/DateHumanizeTests.cs b/src/Humanizer.Tests/Localisation/th/DateHumanizeTests.cs similarity index 91% rename from src/Humanizer.Tests/Localisation/th-TH/DateHumanizeTests.cs rename to src/Humanizer.Tests/Localisation/th/DateHumanizeTests.cs index 8c33964d6..dc5a9d67e 100644 --- a/src/Humanizer.Tests/Localisation/th-TH/DateHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/th/DateHumanizeTests.cs @@ -1,6 +1,6 @@ -namespace thTH; +namespace th; -[UseCulture("th-TH")] +[UseCulture("th")] public class DateHumanizeTests { [Theory] diff --git a/src/Humanizer.Tests/Localisation/th-TH/NumberToWordsTests.cs b/src/Humanizer.Tests/Localisation/th/NumberToWordsTests.cs similarity index 98% rename from src/Humanizer.Tests/Localisation/th-TH/NumberToWordsTests.cs rename to src/Humanizer.Tests/Localisation/th/NumberToWordsTests.cs index 10e8002f1..2007fd50c 100644 --- a/src/Humanizer.Tests/Localisation/th-TH/NumberToWordsTests.cs +++ b/src/Humanizer.Tests/Localisation/th/NumberToWordsTests.cs @@ -1,6 +1,6 @@ -namespace thTH; +namespace th; -[UseCulture("th-TH")] +[UseCulture("th")] public class NumberToWordsTests { [InlineData(1, "หนึ่ง")] diff --git a/src/Humanizer/Configuration/FormatterRegistry.cs b/src/Humanizer/Configuration/FormatterRegistry.cs index 3b7ec6917..fd0499907 100644 --- a/src/Humanizer/Configuration/FormatterRegistry.cs +++ b/src/Humanizer/Configuration/FormatterRegistry.cs @@ -1,4 +1,4 @@ -namespace Humanizer; +namespace Humanizer; class FormatterRegistry : LocaliserRegistry { @@ -55,7 +55,7 @@ public FormatterRegistry() RegisterDefaultFormatter("zh-CN"); RegisterDefaultFormatter("zh-Hans"); RegisterDefaultFormatter("zh-Hant"); - RegisterDefaultFormatter("th-TH"); + RegisterDefaultFormatter("th"); RegisterDefaultFormatter("en-IN"); Register("lt", c => new LithuanianFormatter(c)); Register("lb", c => new LuxembourgishFormatter(c)); diff --git a/src/Humanizer/Configuration/NumberToWordsConverterRegistry.cs b/src/Humanizer/Configuration/NumberToWordsConverterRegistry.cs index 8dec3df2d..c30cf7143 100644 --- a/src/Humanizer/Configuration/NumberToWordsConverterRegistry.cs +++ b/src/Humanizer/Configuration/NumberToWordsConverterRegistry.cs @@ -1,4 +1,4 @@ -namespace Humanizer; +namespace Humanizer; class NumberToWordsConverterRegistry : LocaliserRegistry { @@ -48,7 +48,7 @@ public NumberToWordsConverterRegistry() Register("ja", new JapaneseNumberToWordsConverter()); Register("ku", new CentralKurdishNumberToWordsConverter()); Register("el", new GreekNumberToWordsConverter()); - Register("th-TH", new ThaiNumberToWordsConverter()); + Register("th", new ThaiNumberToWordsConverter()); Register("lv", new LatvianNumberToWordsConverter()); Register("ko-KR", new KoreanNumberToWordsConverter()); Register("en-IN", new IndianNumberToWordsConverter()); diff --git a/src/Humanizer/Properties/Resources.th-TH.resx b/src/Humanizer/Properties/Resources.th.resx similarity index 100% rename from src/Humanizer/Properties/Resources.th-TH.resx rename to src/Humanizer/Properties/Resources.th.resx