From 7a2432e0854de27e335797ea46161f488bf0b4f3 Mon Sep 17 00:00:00 2001 From: Matasx Date: Mon, 9 Dec 2024 12:45:14 +0100 Subject: [PATCH] Fixup culture info parsing. --- Modules/GenHTTP.Modules.I18n/Parsers/CultureInfoParser.cs | 8 ++++++-- Testing/Acceptance/Modules/I18n/LanguageParserTests.cs | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Modules/GenHTTP.Modules.I18n/Parsers/CultureInfoParser.cs b/Modules/GenHTTP.Modules.I18n/Parsers/CultureInfoParser.cs index 7a620110..9e5460ad 100644 --- a/Modules/GenHTTP.Modules.I18n/Parsers/CultureInfoParser.cs +++ b/Modules/GenHTTP.Modules.I18n/Parsers/CultureInfoParser.cs @@ -116,8 +116,12 @@ public static CultureInfo[] ParseFromLanguage(string? language) } try - { - results.Add(CultureInfo.CreateSpecificCulture(lang)); + { + var parsed = CultureInfo.CreateSpecificCulture(lang); + if (parsed.LCID != CultureInfo.InvariantCulture.LCID) + { + results.Add(parsed); + } } catch (CultureNotFoundException) { diff --git a/Testing/Acceptance/Modules/I18n/LanguageParserTests.cs b/Testing/Acceptance/Modules/I18n/LanguageParserTests.cs index 43069ef6..d22c1dec 100644 --- a/Testing/Acceptance/Modules/I18n/LanguageParserTests.cs +++ b/Testing/Acceptance/Modules/I18n/LanguageParserTests.cs @@ -58,6 +58,7 @@ public sealed class LanguageParserTests new ("en ;q=0.9,fr;q=0.8,de", [Culture("de"), Culture("en"), Culture("fr")]), new ("en; q=0.9 , fr; q= 0.8, de", [Culture("de"), Culture("en"), Culture("fr")]), new ("en-UK;q=0.9,fr;q=0.8,de", [Culture("de"), Culture("en-uk"), Culture("fr")]), + new ("en-UK;q=0.9,ww;q=0.8,de", [Culture("de"), Culture("en-uk")]), ]; [TestMethod]