Translate a Document

Contents
[ ]

Document translation is a frequently needed option in the age of high digitalization. Aspose.Words supports document translation using Google, OpenAI and Anthropic generative language models, which allows developers to translate texts content into more than 300 languages.

Use the translate method to translate your documents into any language represented in the Language enumeration. Note that if the source document contains several languages, the AI-based model will be able to translate all supported languages. If the model cannot recognize the language in some text fragments, then you will be returned a document with these untranslated fragments and with the rest of the text translated.

The following code example shows how to use the Gemini 1.5 Flash model in Aspose.Words to translate a document into Arabic:


FAQ

  1. Q: How do I translate a document using Aspose.Words for Node.js via .NET?
    A: Call the translate method of the Aspose.Words.AI namespace, passing the source Document and a target language from the Language enumeration. The method returns a new Document containing the translated content.

  2. Q: Which AI models can be used for translation?
    A: Aspose.Words supports models from Google, OpenAI, and Anthropic. The example uses the Gemini 1.5 Flash model, but you can select any supported model by configuring the AiModel property before calling translate.

  3. Q: What happens if the source document contains multiple languages?
    A: The translation engine attempts to detect each language fragment and translate it to the target language. Fragments that cannot be recognized remain unchanged in the output document.

  4. Q: Why are some parts of my document not translated?
    A: Untranslated fragments may be due to unsupported source languages, extremely short text that the model cannot identify, or formatting that interferes with language detection. Verify that the source language is among the supported list and consider preprocessing the document to isolate translatable text.

  5. Q: Do I need a separate license for the translation feature?
    A: No additional Aspose.Words license is required. However, you must have valid credentials (API key, token, etc.) for the chosen AI provider (Google, OpenAI, or Anthropic) because the translation is performed by their external service.