Skip to main content
Version: v10.x - Umbraco 10

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 the 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

List of the files with custom html to load at each stage of the translation process. For more info see TranslationProviderViews class.

Methods

Reload

void Reload();

Call from Translation Manager that you might want to reload your settings. Most likely caused when the user saves settings in the UI.

Active

bool Active();

Check that the provider is active (the provider must be active to show as an option to the users). 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. (usually, do the language pairs match something we can do?).

GetTargetLanguages

IEnumerable<string> GetTargetLanguages(string sourceLanguage);

Request to show all the target languages that can be translated from the selected source language.

Submit

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

Submit a job to the TranslationJob service, 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 acceptable to the receiving 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 should load the content from the service back into the translation job and change the status of any translated nodes within the job. It should then return this to Translation Manager as a successful 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 'received'.

Cancel

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

Cancel the job, status will return to created (and unsubmitted).

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 from the site completely.

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