Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ITranslationProvider.LoadTranslationsAsync() #15886

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Use IAsyncEnumerable
  • Loading branch information
hishamco committed Apr 26, 2024
commit 93a802ec231bc0c54f379dec605a11b571ed0a26
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,11 @@ public virtual IEnumerable<LocalizedString> 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();
}

/// <inheritdocs />
Expand Down Expand Up @@ -120,7 +122,7 @@ private async IAsyncEnumerable<LocalizedString> GetAllStringsAsync(CultureInfo c
}
}

private async Task<List<LocalizedString>> GetAllStringsFromCultureHierarchyAsync(CultureInfo culture)
private async IAsyncEnumerable<LocalizedString> GetAllStringsFromCultureHierarchyAsync(CultureInfo culture)
{
var currentCulture = culture;
var allLocalizedStrings = new List<LocalizedString>();
Expand All @@ -135,15 +137,13 @@ private async Task<List<LocalizedString>> 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.")]
Expand Down
Loading