Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
Document translation is a frequently needed option in the age of high digitalization. Aspose.Words supports document translation using Google 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 Google 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:
Document doc = new Document("Document.docx");
String apiKey = System.getenv("API_KEY");
IAiModelText model = (IAiModelText)AiModel.create(AiModelType.GEMINI_15_FLASH).withApiKey(apiKey);
Document translatedDoc = model.translate(doc, Language.ARABIC);
translatedDoc.save("AI.AiTranslate.docx");Q: Do I need a Google API key to use the translation feature?
A: Yes. The translation functionality relies on Google generative models, so you must provide a valid API key when creating the AiModel instance.
Q: Which languages can I translate to?
A: Any language listed in the Language enumeration (over 300 languages) is supported. Use Language.<LANGUAGE> to specify the target language.
Q: Can I translate only a part of a document, such as a single section?
A: The translate method works on the whole Document object. To translate a specific part, extract that part into a separate Document, translate it, and then replace the original content.
Q: What happens if the source document contains multiple languages?
A: The model attempts to detect and translate each language it recognizes. Segments in unsupported or unrecognizable languages remain unchanged in the output document.
Q: Can I choose a different AI model for translation?
A: Yes. When creating the model, use AiModel.create(AiModelType.<MODEL>) with any supported model type (e.g., GEMINI_15_FLASH, GEMINI_1_0_PRO). The chosen model determines translation quality and speed.
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.