Translator.Translate

Translator Translate method. Translates the provided document into the specified target language. This operation leverages the connected AI model for content translating.

Translate(string, string, AiModelLanguage)

Translates the provided document into the specified target language. This operation leverages the connected AI model for content translating.

public static void Translate(string inputFile, string outputFile, AiModel model, Language language)
ParameterTypeDescription
inputFileStringThe input file name.
outputFileStringThe output file name.
modelAiModelSpecifies the AI model responsible for generating the summary of a document.
languageLanguageThe target language for AI-powered text translation.

Remarks

If the output format is an image (BMP, EMF, EPS, GIF, JPEG, PNG, or WebP), each page of the output will be saved as a separate file. The specified output file name will be used to generate file names for each part following the rule: outputFile_partIndex.extension.

If the output format is TIFF, the output will be saved as a single multi-frame TIFF file.

Examples

Shows how to create standard OpenAiModel and perform document translation.

string apiKey = Environment.GetEnvironmentVariable("GPT4OMINI_API_KEY", EnvironmentVariableTarget.User);
AiModel model = OpenAiModel.Create(AiModelType.Gpt4OMini, apiKey);

Translator.Translate(MyDir + "SimpleAI.docx", ArtifactsDir + "Translate.docx", model, Language.Ukrainian);

See Also


Translate(string, string, SaveFormatAiModelLanguage)

Translates the provided document into the specified target language. This operation leverages the connected AI model for content translating.

public static void Translate(string inputFile, string outputFile, SaveFormat saveFormat, 
    AiModel model, Language language)
ParameterTypeDescription
inputFileStringThe input file name.
outputFileStringThe output file name.
saveFormatSaveFormatThe save format.
modelAiModelSpecifies the AI model responsible for generating the summary of a document.
languageLanguageThe target language for AI-powered text translation.

Remarks

If the output format is an image (BMP, EMF, EPS, GIF, JPEG, PNG, or WebP), each page of the output will be saved as a separate file. The specified output file name will be used to generate file names for each part following the rule: outputFile_partIndex.extension.

If the output format is TIFF, the output will be saved as a single multi-frame TIFF file.

See Also


Translate(Stream, Stream, SaveFormatAiModelLanguage)

Translates the provided document into the specified target language. This operation leverages the connected AI model for content translating.

public static void Translate(Stream inputStream, Stream outputStream, SaveFormat saveFormat, 
    AiModel model, Language language)
ParameterTypeDescription
inputStreamStreamThe input stream.
outputStreamStreamThe output stream.
saveFormatSaveFormatThe save format.
modelAiModelSpecifies the AI model responsible for generating the summary of a document.
languageLanguageThe target language for AI-powered text translation.

Remarks

If the output format is an image (BMP, EMF, EPS, GIF, JPEG, PNG, or WebP), only the first page of the output will be saved to the specified stream.

If the output format is TIFF, the output will be saved as a single multi-frame TIFF to the specified stream.

See Also