[FA-4] Adds an event bus infrastructure, a RabbitMQ implementation and rewires existing mutations on NovelService to utilize it.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using DeepL;
|
||||
using DeepL.Model;
|
||||
using FictionArchive.Service.TranslationService.Models;
|
||||
using FictionArchive.Service.TranslationService.Models.Enums;
|
||||
using Language = FictionArchive.Common.Enums.Language;
|
||||
|
||||
namespace FictionArchive.Service.TranslationService.Services.TranslationEngines.DeepLTranslate;
|
||||
@@ -31,11 +32,20 @@ public class DeepLTranslationEngine : ITranslationEngine
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<string?> GetTranslation(string body, Language from, Language to)
|
||||
public async Task<TranslationResult> GetTranslation(string body, Language from, Language to)
|
||||
{
|
||||
TextResult translationResult = await _deepLClient.TranslateTextAsync(body, GetLanguageCode(from), GetLanguageCode(to));
|
||||
_logger.LogInformation("Translated text. Usage statistics: CHARACTERS BILLED {TranslationResultBilledCharacters}", translationResult.BilledCharacters);
|
||||
return translationResult.Text;
|
||||
return new TranslationResult()
|
||||
{
|
||||
OriginalText = body,
|
||||
From = from,
|
||||
To = to,
|
||||
TranslationEngineKey = Key,
|
||||
BilledCharacterCount = (uint)translationResult.BilledCharacters,
|
||||
Status = TranslationRequestStatus.Success,
|
||||
TranslatedText = translationResult.Text
|
||||
};
|
||||
}
|
||||
|
||||
private string GetLanguageCode(Language language)
|
||||
|
||||
@@ -6,5 +6,5 @@ namespace FictionArchive.Service.TranslationService.Services.TranslationEngines;
|
||||
public interface ITranslationEngine
|
||||
{
|
||||
public TranslationEngineDescriptor Descriptor { get; }
|
||||
public Task<string?> GetTranslation(string body, Language from, Language to);
|
||||
public Task<TranslationResult> GetTranslation(string body, Language from, Language to);
|
||||
}
|
||||
Reference in New Issue
Block a user