Translate Word, PDF, Web documents in C++

C++ solution for translating documents using AI

Seamless integration with Google Gemini generative language models provides extensive AI-based document processing capabilities for C++ applications.

View code snippet

Translate Documents to 300+ Languages in C++

Automate document translation using Google Gemini AI models with Aspose.Words for C++. Translate DOC, DOCX, RTF, PDF, HTML, Markdown, ODT, TXT, and EPUB files into over 300 languages while preserving the original layout and formatting. The AI-based engine detects the source language automatically — even in multi-language documents — and leaves untranslated only those fragments it cannot identify.

Why Developers Choose Aspose.Words for Document Translation

  • Single API call to translate an entire document
  • Automatic source-language detection for mixed-language documents
  • Output preserved in the original format and layout
  • Support for DOC, DOCX, RTF, PDF, ODT, HTML, Markdown, TXT, EPUB, and more

Authentication requires a Google API key. For a full list of supported AI models, see the API Reference.

Start translating documents in C++ today — try the live demo above.

Example code in C++ for translating a document
Select the target format from the list
Run code
dotnet add package Aspose.Words.Cpp
Copy
auto doc = System::MakeObject<Aspose::Words::Document>(u"Document.docx");
auto apiKey = System::Environment::GetEnvironmentVariable(u"API_KEY");

// Use Google generative language models.
System::SharedPtr<Aspose::Words::AI::AiModel> model = Aspose::Words::AI::AiModel::Create(Aspose::Words::AI::AiModelType::GeminiFlashLatest)->WithApiKey(apiKey);

auto translatedDoc = model->Translate(doc, Aspose::Words::AI::Language::Arabic);
translatedDoc->Save(u"Output.docx");
auto doc = System::MakeObject<Aspose::Words::Document>(u"Document.docx");
// Pass an empty string if the self-hosted model does not require an API key.
auto model = System::MakeObject<CustomAiModel>(u"my-model-24b", u"https://your-server.com/v1");
model->WithApiKey(u"");

auto translatedDoc = model->Translate(doc, Aspose::Words::AI::Language::Arabic);
translatedDoc->Save(u"Output.docx");

class CustomAiModel : public Aspose::Words::AI::OpenAiModel
{
private:
    System::String mUrl;
public:
    CustomAiModel(System::String name, System::String url) : OpenAiModel(name) { mUrl = url; }
    System::String get_Url() override { return mUrl; }
};
Run code

How to translate a document in C++

  1. Install Aspose.Words for C++.
  2. Add a library reference (import the library) to your C++ project.
  3. Open the source file in C++.
  4. Invoke Translate method, passing in your document along with the target Language.
  5. Once completed, you will receive a translated document that you can save as a new file in the format you need.

C++ library to translate documents

There are three options to install Aspose.Words for C++ to your developer environment. Please choose one that resembles your needs and follow the step-by-step instructions:

System Requirements

You can use this C++ library to develop software on Microsoft Windows, Linux and macOS operating systems:

  • GCC >= 6.3.0 and Clang >= 3.9.1 are required for Linux
  • Xcode >= 12.5.1, Clang and libc++ are required for macOS

If you develop software for Linux or macOS, please check information on additional library dependencies (fontconfig and mesa-glu open-source packages) in Product Documentation.

5%

Subscribe to Aspose Product Updates

Get monthly newsletters and offers directly delivered to your mailbox.

© Aspose Pty Ltd 2001-2026. All Rights Reserved.