Skip to content

Commit 32e98aa

Browse files
committed
prevent looping
1 parent 95187a8 commit 32e98aa

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

Localization.AspNetCore.EntityFramework/Managers/LocalizationManager.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ public LocalizedString GetResource(string resourceKey, CultureInfo culture)
8181
{
8282
if (string.IsNullOrWhiteSpace(resourceKey))
8383
throw new ArgumentException(nameof(resourceKey));
84-
85-
if (!_cacheProvider.TryGetValue(resourceKey, culture, out var value))
84+
85+
if (!_cacheProvider.TryGetValue(resourceKey, culture, out var value))
8686
{
8787
using (var scope = _serviceProvider.GetScopedService(out T context))
8888
{
@@ -104,7 +104,7 @@ public LocalizedString GetResource(string resourceKey, CultureInfo culture)
104104
}
105105

106106
value = item?.Value ?? string.Empty;
107-
107+
108108
if (string.IsNullOrWhiteSpace(value))
109109
switch (_localizerSettings.FallBackBehavior)
110110
{
@@ -113,11 +113,15 @@ public LocalizedString GetResource(string resourceKey, CultureInfo culture)
113113
break;
114114

115115
case FallBackBehaviorEnum.DefaultCulture:
116-
return GetResource(resourceKey, DefaultCulture);
116+
if (culture.Name != DefaultCulture.Name)
117+
return GetResource(resourceKey, DefaultCulture);
118+
break;
117119
}
118120
}
121+
119122
_cacheProvider.Set(resourceKey, culture, value);
120123
}
124+
121125
return new LocalizedString(resourceKey, value!);
122126
}
123127

0 commit comments

Comments
 (0)