Skip to content

Commit

Permalink
Fixup culture info parsing.
Browse files Browse the repository at this point in the history
  • Loading branch information
Matasx committed Dec 9, 2024
1 parent 5df0eaa commit 7a2432e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Modules/GenHTTP.Modules.I18n/Parsers/CultureInfoParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
1 change: 1 addition & 0 deletions Testing/Acceptance/Modules/I18n/LanguageParserTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit 7a2432e

Please sign in to comment.