diff --git a/src/OrchardCore/OrchardCore.Localization.Core/PortableObject/PortableObjectStringLocalizer.cs b/src/OrchardCore/OrchardCore.Localization.Core/PortableObject/PortableObjectStringLocalizer.cs index b046ca127d5..db7616e9ada 100644 --- a/src/OrchardCore/OrchardCore.Localization.Core/PortableObject/PortableObjectStringLocalizer.cs +++ b/src/OrchardCore/OrchardCore.Localization.Core/PortableObject/PortableObjectStringLocalizer.cs @@ -71,9 +71,11 @@ public virtual IEnumerable GetAllStrings(bool includeParentCult { var culture = CultureInfo.CurrentUICulture; - return includeParentCultures - ? GetAllStringsFromCultureHierarchyAsync(culture).GetAwaiter().GetResult() - : GetAllStringsAsync(culture).ToEnumerable(); + var localizedStrings = includeParentCultures + ? GetAllStringsFromCultureHierarchyAsync(culture) + : GetAllStringsAsync(culture); + + return localizedStrings.ToEnumerable(); } /// @@ -120,7 +122,7 @@ private async IAsyncEnumerable GetAllStringsAsync(CultureInfo c } } - private async Task> GetAllStringsFromCultureHierarchyAsync(CultureInfo culture) + private async IAsyncEnumerable GetAllStringsFromCultureHierarchyAsync(CultureInfo culture) { var currentCulture = culture; var allLocalizedStrings = new List(); @@ -135,15 +137,13 @@ private async Task> GetAllStringsFromCultureHierarchyAsync { if (!allLocalizedStrings.Any(ls => ls.Name == localizedString.Name)) { - allLocalizedStrings.Add(localizedString); + yield return localizedString; } } } currentCulture = currentCulture.Parent; } while (currentCulture != currentCulture.Parent); - - return allLocalizedStrings; } [Obsolete("This method is deprecated, please use GetTranslationAsync instead.")]