
Aspose.Words now offers advanced AI-powered text translation capabilities through the Aspose.Words.AI namespace. This feature leverages Google’s generative language models, enabling developers to seamlessly translate document content into various languages with minimal effort. Whether you are localizing a document or collaborating across different language regions, Aspose.Words makes it simple to integrate translation functionality into your applications.
This article covers the following topics:
How to Translate a Document
To translate a document, you can use the Translate method provided by the IAiModelText interface. Start by creating an AI model instance, setting the appropriate API key, and specifying the target language using the Language enumeration. The translation process is efficient, allowing developers to handle multilingual documents with ease.
Here’s an example of how to translate a Word document using Aspose.Words:
Document doc = new Document(MyDir + "Document.docx");
string apiKey = Environment.GetEnvironmentVariable("API_KEY");
// Use Google generative language models.
IAiModelText model = (IAiModelText)AiModel.Create(AiModelType.Gemini15Flash).WithApiKey(apiKey);
Document translatedDoc = model.Translate(doc, Language.Arabic);
translatedDoc.Save(ArtifactsDir + "AI.AiTranslate.docx");
Why Use Aspose.Words for Translation?
- Seamless Integration: Easily add translation functionality to your applications.
- Customizable Options: Translate content into various languages with precise control.
- Efficiency: Utilize AI-driven models for fast and reliable translations.
Aspose.Words simplifies the process of translating documents, allowing developers to focus on delivering high-quality multilingual solutions. For more details, explore the Aspose.Words API documentation.