Azure

Getting Started with Azure Translator

Azure Translator is a neural machine translation service supporting 100+ languages. This guide covers text translation, document translation, language detection, transliteration, custom models, and best practices.

T
Tran Quang
Author
⏱️5 min read
📅March 19, 2025
Azure & Cloud
👀Tech
#Storage#Microsoft#Best Practices

Azure Translator is a cloud-based neural machine translation service that is part of Azure AI Services. It supports over 100 languages and dialects, enabling real-time text translation, transliteration, language detection, and dictionary lookups. Whether you are building a multilingual app, translating customer support tickets, or processing documents globally, Azure Translator provides a fast and accurate solution.

What is Azure Translator?

Azure Translator (formerly Microsoft Translator Text API) uses state-of-the-art neural machine translation (NMT) models to deliver high-quality translations. It offers:

  • Text Translation: Translate text between supported languages in real time.
  • Document Translation: Asynchronously translate entire documents (DOCX, PDF, XLSX, etc.) while preserving layout and formatting.
  • Custom Translator: Train custom translation models using your domain-specific terminology and parallel corpora.
  • Transliteration: Convert text from one script to another (e.g., Japanese Hiragana to Latin).
  • Language Detection: Identify which language a piece of text is written in.
  • Dictionary Lookup: Find alternative translations and example sentences.

Supported Languages

Azure Translator supports over 100 languages including English, Vietnamese, Chinese (Simplified/Traditional), Japanese, Korean, French, German, Spanish, Arabic, and many more. The full list is available via the /languages endpoint.

Setting Up Azure Translator

Step 1: Create a Translator Resource

  1. Go to the Azure Portal.
  2. Click Create a resource > AI + Machine Learning > Translator.
  3. Configure:
    • Subscription and resource group.
    • Region (choose Global or a specific region for data residency).
    • Pricing tier: Free F0 (2M characters/month) or Standard S1.
  4. Click Review + Create and then Create.
  5. After deployment, copy the Key and Endpoint from the Keys and Endpoint tab.

Step 2: Install the SDK

# Python
pip install azure-ai-translation-text

# .NET
dotnet add package Azure.AI.Translation.Text

Text Translation

Python Example

from azure.ai.translation.text import TextTranslationClient
from azure.ai.translation.text.models import InputTextItem
from azure.core.credentials import AzureKeyCredential

credential = AzureKeyCredential("<your-translator-key>")
client = TextTranslationClient(credential=credential)

# Translate English to Vietnamese and Japanese
response = client.translate(
    body=[InputTextItem(text="Hello, how are you?")],
    to_language=["vi", "ja"],
    from_language="en"
)

for translation in response[0].translations:
    print(f"{translation.to}: {translation.text}")
# Output:
# vi: Xin chào, bạn khỏe không?
# ja: こんにちは、お元気ですか?

Translating Multiple Texts at Once (Batch)

texts = [
    InputTextItem(text="Good morning"),
    InputTextItem(text="Thank you very much"),
    InputTextItem(text="See you later"),
]

response = client.translate(body=texts, to_language=["vi"])
for i, result in enumerate(response):
    print(f"{texts[i].text} -> {result.translations[0].text}")

C# Example

using Azure;
using Azure.AI.Translation.Text;

var client = new TextTranslationClient(
    new AzureKeyCredential("<your-key>"),
    new Uri("https://api.cognitive.microsofttranslator.com")
);

var response = await client.TranslateAsync(
    targetLanguages: new[] { "vi", "fr" },
    content: new[] { "Azure Translator is amazing!" }
);

foreach (var item in response.Value)
    foreach (var t in item.Translations)
        Console.WriteLine($"{t.To}: {t.Text}");

Language Detection

response = client.find_sentence_length(
    body=[InputTextItem(text="Bonjour tout le monde!")]
)

# Use detect endpoint for language detection
detect_response = client.detect(body=[InputTextItem(text="Bonjour tout le monde!")])
for result in detect_response:
    print(f"Language: {result.language}, Confidence: {result.score:.2f}")
# Output: Language: fr, Confidence: 1.00

Transliteration

Convert text between scripts without changing the language:

# Convert Japanese Katakana to Latin
response = client.transliterate(
    body=[InputTextItem(text="コンピューター")],
    language="ja",
    from_script="Jpan",
    to_script="Latn"
)
print(response[0].text)  # Output: konpyuutaa

Dictionary Lookup

response = client.lookup_dictionary_entries(
    body=[InputTextItem(text="fly")],
    from_language="en",
    to_language="vi"
)

for entry in response[0].translations:
    print(f"{entry.display_target} (confidence: {entry.confidence:.2f})")

Document Translation

Document Translation is an asynchronous batch operation that translates entire documents while preserving their original formatting (headers, tables, images).

from azure.ai.translation.document import DocumentTranslationClient
from azure.ai.translation.document.models import DocumentTranslationInput, TranslationTarget

client = DocumentTranslationClient(
    endpoint="https://<your-resource>.cognitiveservices.azure.com/",
    credential=AzureKeyCredential("<your-key>")
)

poller = client.begin_translation(
    inputs=[
        DocumentTranslationInput(
            source_url="https://<storage>.blob.core.windows.net/source?<sas-token>",
            targets=[
                TranslationTarget(
                    target_url="https://<storage>.blob.core.windows.net/output-vi?<sas-token>",
                    language="vi"
                )
            ]
        )
    ]
)

result = poller.result()
for doc in result:
    print(f"Document: {doc.source_document_url}")
    print(f"Status: {doc.status}")
    if doc.translated_document:
        print(f"Translated to: {doc.translated_document.target_language}")

Custom Translator

Train a custom NMT model using your domain-specific parallel data (source–target sentence pairs) at Custom Translator Portal. Once trained, deploy the model and use it via a custom category ID:

response = client.translate(
    body=[InputTextItem(text="The batch process failed with error code 0x80")],
    to_language=["vi"],
    category="<your-custom-category-id>"  # Use your domain-specific model
)

Use Cases

  1. Customer support: Automatically translate incoming support tickets to the agent's language.
  2. E-commerce: Localize product descriptions and reviews.
  3. Healthcare: Translate medical documents for cross-border patient care.
  4. Education: Build multilingual learning platforms.
  5. Real-time chat: Add live translation to messaging apps.
  6. Document workflows: Translate contracts, reports, and manuals at scale.

Pricing

Feature Free (F0) Standard (S1)
Text Translation 2M chars/month $10 per 1M characters
Document Translation Not included $15 per 1M source chars
Custom Translator Not included $40 per 1M source chars

Best Practices

  1. Batch requests: Send multiple texts in a single API call (up to 100 items, 50,000 characters total per request).
  2. Cache translations: For static content, cache translated strings in your database to reduce API calls.
  3. Specify source language: Providing from_language improves speed and avoids auto-detection overhead.
  4. Use Custom Translator for domain-specific terminology to improve accuracy.
  5. Handle rate limits: Implement retry with exponential backoff for 429 responses.

Conclusion

Azure Translator is a powerful, versatile translation service that removes language barriers for global applications. With neural machine translation quality, document-level translation, custom model training, and a generous free tier, it is the ideal choice for building multilingual solutions at any scale.

For full documentation, visit Azure Translator Documentation.

Found this helpful?

Share it with others who might benefit from this content.

Related Articles

Continue exploring these related topics

Want to Learn More?

Explore more articles and tutorials on software engineering, cloud technologies, and best practices. Join the community of passionate developers!