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
Merge branch "main" into hishamco/translation-provider
  • Loading branch information
hishamco authored May 2, 2024
commit 239bc7f5afdd749535ce71ef97601ab2e6178b16
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
}

[Fact]
public async Task GetDictionaryReturnsDictionaryWithPluralRuleAndCultureIfNoTranslationsExists()

Check failure on line 23 in test/OrchardCore.Tests/Localization/LocalizationManagerTests.cs

View workflow job for this annotation

GitHub Actions / Build & Test (ubuntu-latest)

This async method lacks "await" operators and will run synchronously. Consider using the "await" operator to await non-blocking API calls, or "await Task.Run(...)" to do CPU-bound work on a background thread.

Check failure on line 23 in test/OrchardCore.Tests/Localization/LocalizationManagerTests.cs

View workflow job for this annotation

GitHub Actions / Build & Test (ubuntu-latest)

This async method lacks "await" operators and will run synchronously. Consider using the "await" operator to await non-blocking API calls, or "await Task.Run(...)" to do CPU-bound work on a background thread.

Check failure on line 23 in test/OrchardCore.Tests/Localization/LocalizationManagerTests.cs

View workflow job for this annotation

GitHub Actions / Build & Test (windows-latest)

This async method lacks "await" operators and will run synchronously. Consider using the "await" operator to await non-blocking API calls, or "await Task.Run(...)" to do CPU-bound work on a background thread.

Check failure on line 23 in test/OrchardCore.Tests/Localization/LocalizationManagerTests.cs

View workflow job for this annotation

GitHub Actions / Build & Test (windows-latest)

This async method lacks "await" operators and will run synchronously. Consider using the "await" operator to await non-blocking API calls, or "await Task.Run(...)" to do CPU-bound work on a background thread.
{
_translationProvider.Setup(o => o.LoadTranslationsAsync(
It.Is<string>(culture => culture == "cs"),
Expand All @@ -29,14 +29,14 @@

var manager = new LocalizationManager(new[] { _pluralRuleProvider.Object }, new[] { _translationProvider.Object }, _memoryCache);

var dictionary = await manager.GetDictionaryAsync(new CultureInfo("cs"));
var dictionary = manager.GetDictionary(CultureInfo.GetCultureInfo("cs"));

Check failure on line 32 in test/OrchardCore.Tests/Localization/LocalizationManagerTests.cs

View workflow job for this annotation

GitHub Actions / Build & Test (ubuntu-latest)

"LocalizationManager" does not contain a definition for "GetDictionary" and no accessible extension method "GetDictionary" accepting a first argument of type "LocalizationManager" could be found (are you missing a using directive or an assembly reference?)

Check failure on line 32 in test/OrchardCore.Tests/Localization/LocalizationManagerTests.cs

View workflow job for this annotation

GitHub Actions / Build & Test (ubuntu-latest)

"LocalizationManager" does not contain a definition for "GetDictionary" and no accessible extension method "GetDictionary" accepting a first argument of type "LocalizationManager" could be found (are you missing a using directive or an assembly reference?)

Check failure on line 32 in test/OrchardCore.Tests/Localization/LocalizationManagerTests.cs

View workflow job for this annotation

GitHub Actions / Build & Test (windows-latest)

"LocalizationManager" does not contain a definition for "GetDictionary" and no accessible extension method "GetDictionary" accepting a first argument of type "LocalizationManager" could be found (are you missing a using directive or an assembly reference?)

Check failure on line 32 in test/OrchardCore.Tests/Localization/LocalizationManagerTests.cs

View workflow job for this annotation

GitHub Actions / Build & Test (windows-latest)

"LocalizationManager" does not contain a definition for "GetDictionary" and no accessible extension method "GetDictionary" accepting a first argument of type "LocalizationManager" could be found (are you missing a using directive or an assembly reference?)

Assert.Equal("cs", dictionary.CultureName);

Check failure on line 34 in test/OrchardCore.Tests/Localization/LocalizationManagerTests.cs

View workflow job for this annotation

GitHub Actions / Build & Test (ubuntu-latest)

Argument 2: cannot convert from "method group" to "System.Collections.Generic.IAsyncEnumerable<char>?"

Check failure on line 34 in test/OrchardCore.Tests/Localization/LocalizationManagerTests.cs

View workflow job for this annotation

GitHub Actions / Build & Test (ubuntu-latest)

Argument 2: cannot convert from "method group" to "System.Collections.Generic.IAsyncEnumerable<char>?"

Check failure on line 34 in test/OrchardCore.Tests/Localization/LocalizationManagerTests.cs

View workflow job for this annotation

GitHub Actions / Build & Test (windows-latest)

Argument 2: cannot convert from "method group" to "System.Collections.Generic.IAsyncEnumerable<char>?"

Check failure on line 34 in test/OrchardCore.Tests/Localization/LocalizationManagerTests.cs

View workflow job for this annotation

GitHub Actions / Build & Test (windows-latest)

Argument 2: cannot convert from "method group" to "System.Collections.Generic.IAsyncEnumerable<char>?"
Assert.Equal(PluralizationRule.Czech, dictionary.PluralRule);
}

[Fact]
public async Task GetDictionaryReturnsDictionaryWithTranslationsFromProvider()

Check failure on line 39 in test/OrchardCore.Tests/Localization/LocalizationManagerTests.cs

View workflow job for this annotation

GitHub Actions / Build & Test (ubuntu-latest)

This async method lacks "await" operators and will run synchronously. Consider using the "await" operator to await non-blocking API calls, or "await Task.Run(...)" to do CPU-bound work on a background thread.

Check failure on line 39 in test/OrchardCore.Tests/Localization/LocalizationManagerTests.cs

View workflow job for this annotation

GitHub Actions / Build & Test (windows-latest)

This async method lacks "await" operators and will run synchronously. Consider using the "await" operator to await non-blocking API calls, or "await Task.Run(...)" to do CPU-bound work on a background thread.
{
var dictionaryRecord = new CultureDictionaryRecord("ball", "míč", "míče", "míčů");
_translationProvider
Expand All @@ -45,7 +45,7 @@

var manager = new LocalizationManager(new[] { _pluralRuleProvider.Object }, new[] { _translationProvider.Object }, _memoryCache);

var dictionary = await manager.GetDictionaryAsync(new CultureInfo("cs"));
var dictionary = manager.GetDictionary(CultureInfo.GetCultureInfo("cs"));

Check failure on line 48 in test/OrchardCore.Tests/Localization/LocalizationManagerTests.cs

View workflow job for this annotation

GitHub Actions / Build & Test (ubuntu-latest)

"LocalizationManager" does not contain a definition for "GetDictionary" and no accessible extension method "GetDictionary" accepting a first argument of type "LocalizationManager" could be found (are you missing a using directive or an assembly reference?)

Check failure on line 48 in test/OrchardCore.Tests/Localization/LocalizationManagerTests.cs

View workflow job for this annotation

GitHub Actions / Build & Test (windows-latest)

"LocalizationManager" does not contain a definition for "GetDictionary" and no accessible extension method "GetDictionary" accepting a first argument of type "LocalizationManager" could be found (are you missing a using directive or an assembly reference?)
var key = new CultureDictionaryRecordKey { MessageId = "ball" };

dictionary.Translations.TryGetValue(key, out var translations);
Expand All @@ -54,7 +54,7 @@
}

[Fact]
public async Task GetDictionarySelectsPluralRuleFromProviderWithHigherPriority()

Check failure on line 57 in test/OrchardCore.Tests/Localization/LocalizationManagerTests.cs

View workflow job for this annotation

GitHub Actions / Build & Test (ubuntu-latest)

This async method lacks "await" operators and will run synchronously. Consider using the "await" operator to await non-blocking API calls, or "await Task.Run(...)" to do CPU-bound work on a background thread.

Check failure on line 57 in test/OrchardCore.Tests/Localization/LocalizationManagerTests.cs

View workflow job for this annotation

GitHub Actions / Build & Test (windows-latest)

This async method lacks "await" operators and will run synchronously. Consider using the "await" operator to await non-blocking API calls, or "await Task.Run(...)" to do CPU-bound work on a background thread.
{
PluralizationRuleDelegate csPluralRuleOverride = n => ((n == 1) ? 0 : (n >= 2 && n <= 4) ? 1 : 0);

Expand All @@ -69,7 +69,7 @@

var manager = new LocalizationManager(new[] { _pluralRuleProvider.Object, highPriorityRuleProvider.Object }, new[] { _translationProvider.Object }, _memoryCache);

var dictionary = await manager.GetDictionaryAsync(new CultureInfo("cs"));
var dictionary = manager.GetDictionary(CultureInfo.GetCultureInfo("cs"));

Check failure on line 72 in test/OrchardCore.Tests/Localization/LocalizationManagerTests.cs

View workflow job for this annotation

GitHub Actions / Build & Test (ubuntu-latest)

"LocalizationManager" does not contain a definition for "GetDictionary" and no accessible extension method "GetDictionary" accepting a first argument of type "LocalizationManager" could be found (are you missing a using directive or an assembly reference?)

Check failure on line 72 in test/OrchardCore.Tests/Localization/LocalizationManagerTests.cs

View workflow job for this annotation

GitHub Actions / Build & Test (windows-latest)

"LocalizationManager" does not contain a definition for "GetDictionary" and no accessible extension method "GetDictionary" accepting a first argument of type "LocalizationManager" could be found (are you missing a using directive or an assembly reference?)

Assert.Equal(dictionary.PluralRule, csPluralRuleOverride);
}
Expand Down
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.