Updated translation service and finished splitting out responsibilities for now
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
using FictionArchive.Service.Shared.Services.Database;
|
||||
using FictionArchive.Service.TranslationService.Models.Database;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace FictionArchive.Service.TranslationService.Services.Database;
|
||||
|
||||
public class TranslationServiceDbContext : FictionArchiveDbContext
|
||||
{
|
||||
public DbSet<TranslationRequest> TranslationRequests { get; set; }
|
||||
|
||||
public TranslationServiceDbContext(DbContextOptions options, ILogger<TranslationServiceDbContext> logger) : base(options, logger)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -5,15 +5,15 @@ using Language = FictionArchive.Common.Enums.Language;
|
||||
|
||||
namespace FictionArchive.Service.TranslationService.Services.TranslationEngines.DeepLTranslate;
|
||||
|
||||
public class DeepLTranslationAdapater : ITranslationEngineAdapter
|
||||
public class DeepLTranslationEngine : ITranslationEngine
|
||||
{
|
||||
private readonly DeepLClient _deepLClient;
|
||||
private readonly ILogger<DeepLTranslationAdapater> _logger;
|
||||
private readonly ILogger<DeepLTranslationEngine> _logger;
|
||||
|
||||
private const string DisplayName = "DeepL";
|
||||
private const string Key = "deepl";
|
||||
|
||||
public DeepLTranslationAdapater(DeepLClient deepLClient, ILogger<DeepLTranslationAdapater> logger)
|
||||
public DeepLTranslationEngine(DeepLClient deepLClient, ILogger<DeepLTranslationEngine> logger)
|
||||
{
|
||||
_deepLClient = deepLClient;
|
||||
_logger = logger;
|
||||
@@ -45,7 +45,8 @@ public class DeepLTranslationAdapater : ITranslationEngineAdapter
|
||||
Language.En => LanguageCode.EnglishAmerican,
|
||||
Language.Kr => LanguageCode.Korean,
|
||||
Language.Ch => LanguageCode.Chinese,
|
||||
Language.Ja => LanguageCode.Japanese
|
||||
Language.Ja => LanguageCode.Japanese,
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(language), language, null)
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@ using FictionArchive.Service.TranslationService.Models;
|
||||
|
||||
namespace FictionArchive.Service.TranslationService.Services.TranslationEngines;
|
||||
|
||||
public interface ITranslationEngineAdapter
|
||||
public interface ITranslationEngine
|
||||
{
|
||||
public TranslationEngineDescriptor Descriptor { get; }
|
||||
public Task<string?> GetTranslation(string body, Language from, Language to);
|
||||
Reference in New Issue
Block a user