Translate
Contents
[
Hide
]AsposeLlmModel.Translate method
Translates the provided document into the specified target language.
public override Document Translate(Document sourceDocument, Language targetLanguage)
Remarks
Same approach as Translate: the whole document is sent as one piece of text marked with run separators, to preserve the original formatting by restoring the translation back into the original runs. A small local model damages a run separator more often than a cloud model, so any run that could not be restored this way is translated again individually, by Language).
Examples
Shows how to translate a document with a local model.
Document doc = new Document(MyDir + "Document.docx");
using (AsposeLlmModel model = new AsposeLlmModel("Qwen25_3BPresetCpu"))
{
Document translatedDoc = model.Translate(doc, Language.German);
translatedDoc.Save(ArtifactsDir + "AI.AsposeLlmTranslate.docx");
}
See Also
- class Document
- enum Language
- class AsposeLlmModel
- namespace Aspose.Words.AI
- assembly Aspose.Words