Created
June 15, 2021 08:18
-
-
Save KevinJump/623b8d1931a4cc398a6adbb24da2d80c to your computer and use it in GitHub Desktop.
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
using Jumoo.TranslationManager.Core.Models; | |
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
using Umbraco.Core; | |
namespace Jumoo.TranslationManager.Core.Providers | |
{ | |
public interface ITranslationProvider | |
{ | |
string Name { get; } | |
string Alias { get; } | |
Guid Key { get; } | |
TranslationProviderViews Views { get; } | |
/// <summary> | |
/// called by the app when settings are saved in the backoffice | |
/// </summary> | |
void Reload(); | |
/// <summary> | |
/// simple check function to see if this provider is active | |
/// </summary> | |
/// <returns></returns> | |
bool Active(); | |
/// <summary> | |
/// test to check that this provider would be able to translate | |
/// this job (usally a source/target language check) | |
/// </summary> | |
bool CanTranslate(TranslationJob job); | |
/// <summary> | |
/// workout what the target languages that we can translate | |
/// to given a source language | |
/// </summary> | |
IEnumerable<string> GetTargetLanguages(string sourceLanguage); | |
/// <summary> | |
/// submit the translation job | |
/// </summary> | |
Task<Attempt<TranslationJob>> Submit(TranslationJob job); | |
/// <summary> | |
/// Check the status of the translation job on the | |
/// providers service | |
/// </summary> | |
Task<Attempt<TranslationJob>> Check(TranslationJob job); | |
/// <summary> | |
/// called job has been cancelled inside translation manager | |
/// </summary> | |
/// <remarks> | |
/// Cancelled jobs can be reset by users, so a cancelled job | |
/// may not be gone forever, you probibly don't want to | |
/// delete a job on a third party system when this is | |
/// called, but you may want to mark it / stop translation | |
/// </remarks> | |
Task<Attempt<TranslationJob>> Cancel(TranslationJob job); | |
/// <summary> | |
/// called when a job is removed (deleted) from translation manager | |
/// </summary> | |
/// <remarks> | |
/// Removed jobs are not coming back (bar a DB restore) you | |
/// should be safe to delete these on your side. | |
/// </remarks> | |
Task<Attempt<TranslationJob>> Remove(TranslationJob job); | |
} | |
/// <summary> | |
/// interface for providers supporting the grouping of Jobs | |
/// </summary> | |
public interface IGroupedTranslationProvider | |
{ | |
/// <summary> | |
/// called after a group of jobs have all been submitted, should be used to group | |
/// jobs if provider supports it. | |
/// </summary> | |
/// <remarks> | |
/// <para> | |
/// you should still impliment ITranslationProvider, and your provider will get | |
/// calls to the single Submit for each job - all jobs will have a groupId, which | |
/// marks them in a group, and then at the end this Submit is called. | |
/// </para> | |
/// <para> | |
/// if you support grouping then this call will happen even for single jobs, so | |
/// you can use this submit to do your processing - and assume the single submit | |
/// is just a marker. | |
/// </para> | |
/// </remarks> | |
/// <param name="Jobs"></param> | |
/// <returns></returns> | |
Task<Attempt<IEnumerable<TranslationJob>>> Submit(IEnumerable<TranslationJob> Jobs); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment