Skip to content

ITranslationProvider

public interface ITranslationProvider
{
    string Name { get; }
    string Alias { get; }
    Guid Key { get; }
    TranslationProviderViews Views { get; }
    void Reload();
    bool Active();
    bool CanTranslate(TranslationJob job);
    IEnumerable<string> GetTargetLanguages(string sourceLanguage);
    Task<TranslationAttempt<TranslationJob>> Submit(TranslationJob job);
    Task<TranslationAttempt<TranslationJob>> Check(TranslationJob job);
    Task<TranslationAttempt<TranslationJob>> Cancel(TranslationJob job);
    Task<TranslationAttempt<TranslationJob>> Remove(TranslationJob job);
}

Properties

string Name

Name of the provider - used in dropdowns when user picks or configures provider

string Alias

Alias for provider - used when saving or loading settings

Guid Key

Unique key for the provider - used to identify provider in jobs/

TranslationProviderViews Views

Path to views loaded in the back office for the relevant stage of the process. in a TranslationProviderViews class

Methods

Reload

void Reload();

Call from the translation manager that you might want to reload your settings. probibly caused when the user saves settings in the UI.

Active

bool Active();

Check that the provider is active (so shown or not shown in options) - typically you would check for the presence of an API key and return true if it is set

CanTranslate

bool CanTranslate(TranslationJob job);

Request from translation manager to see if the provider can translate the current job. (usally do the language pairs match something we can do?)

GetTargetLanguages

IEnumerable<string> GetTargetLanguages(string sourceLanguage);

request to show all the target langauges that can be translated from the selected source language

Submit

Task<TranslationAttempt<TranslationJob>> Submit(TranslationJob job);

Submit a job to the "translation serivce" - this is the first time the provider will get the job

This function is responsible for packaging and sending any translation information to your translation service. the translation job will contain all the information required, and the provider is expected to package this into a format acceptible to the receving service and to submit it to that service.

Check

Task<TranslationAttempt<TranslationJob>> Check(TranslationJob job);

Check the status of the translation job.

Check is called either when the user requests a check or the background check process runs.

If a job has been completed since the last check, the check process would be expected to load the content from the service back into the translation job and change the status of any translated nodes within the job. and return this to translation manager as a Successfull check.

Translation manager will then scan the job and change the status accordingly. e.g if all nodes are translated the job will change to 'recevied'

Cancel

Task<TranslationAttempt<TranslationJob>> Cancel(TranslationJob job);

Cancel the job - status will return to unsubmitted (created)

Called when a user cancels a job within translation manager. A Provider would then use this call to cancel any work on the service provider as required.

Remove

Task<TranslationAttempt<TranslationJob>> Remove(TranslationJob job);

Called when the job is being removed (compleatly) from the site

Translation Manager will remove any internal database data for the job but the provider is responsible for cleanup of it's own services, or files.