Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -154,16 +154,9 @@ private static void SetCurrentThreadCulture(RequestCulture requestCulture)
bool fallbackToParentCultures,
int currentDepth)
{
// If the cultureName is an empty string there
// is no chance we can resolve the culture info.
if (cultureName.Equals(string.Empty))
{
return null;
}

var culture = GetCultureInfo(cultureName, supportedCultures);

if (culture == null && fallbackToParentCultures && currentDepth < MaxCultureFallbackDepth)
if (culture == null && fallbackToParentCultures && currentDepth < MaxCultureFallbackDepth && cultureName != CultureInfo.InvariantCulture.Name)
{
try
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class RequestLocalizationMiddlewareTest
[InlineData("zh-Hans-CN", "zh-Hans")]
[InlineData("zh-Hant-TW", "zh-Hant")]
[InlineData("zh-TW", "zh-Hant")]
[InlineData("zh-Hans-CN", "")]
public async Task RequestLocalizationMiddleware_ShouldFallBackToParentCultures_RegradlessOfHyphenSeparatorCheck(string requestedCulture, string parentCulture)
{
using var host = new HostBuilder()
Expand Down
Loading