-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Get translations for resource key added
- Loading branch information
Showing
10 changed files
with
95 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using System; | ||
|
||
namespace idee5.Globalization.Models; | ||
/// <summary> | ||
/// The resource translations | ||
/// </summary> | ||
public record ResourceTranslations : ResourceKey { | ||
public ResourceTranslations(ResourceKey original, Translation[] translations) : base(original) { | ||
Translations = translations ?? throw new ArgumentNullException(nameof(translations)); | ||
} | ||
|
||
/// <summary> | ||
/// Translations of the <see cref="ResourceKey">. | ||
/// </summary> | ||
public Translation[] Translations { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
idee5.Globalization/Queries/GetResourceKeyTranslationsQuery.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using idee5.Common; | ||
using idee5.Globalization.Models; | ||
|
||
namespace idee5.Globalization.Queries; | ||
|
||
/// <summary> | ||
/// The get resource key translations query parameters | ||
/// </summary> | ||
public record GetResourceKeyTranslationsQuery() : ResourceKey, IQuery<ResourceTranslations>; |
32 changes: 32 additions & 0 deletions
32
idee5.Globalization/Queries/GetResourceKeyTranslationsQueryHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using idee5.Common; | ||
using idee5.Globalization.Models; | ||
using idee5.Globalization.Repositories; | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace idee5.Globalization.Queries; | ||
|
||
/// <summary> | ||
/// The get resource key translations query handler | ||
/// </summary> | ||
public class GetResourceKeyTranslationsQueryHandler : IQueryHandlerAsync<GetResourceKeyTranslationsQuery, ResourceTranslations> { | ||
readonly IResourceQueryRepository _repository; | ||
|
||
public GetResourceKeyTranslationsQueryHandler(IResourceQueryRepository repository) { | ||
_repository = repository; | ||
} | ||
|
||
/// <inheritdoc/> | ||
public async Task<ResourceTranslations> HandleAsync(GetResourceKeyTranslationsQuery query, CancellationToken cancellationToken = default) { | ||
if (query is null) { | ||
throw new ArgumentNullException(nameof(query)); | ||
} | ||
List<Resource> res = await _repository.GetAsync(Specifications.OfResourceKey(query)).ConfigureAwait(false); | ||
Translation[] t = res.Select(r => new Translation(r.Language ?? "", r.Value, r.Comment)).ToArray(); | ||
return new(query, t); | ||
} | ||
} |
4 changes: 3 additions & 1 deletion
4
idee5.Globalization/Queries/GetResourceSetsByNameQueryHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters