All skills
microsoft avatar

/azure-ai-translation-document-py

@4a2873f
by microsoftmicrosoft/skills3.1k stars
351

Azure AI Document Translation SDK for batch translation of documents with format preservation. Use for translating Word, PDF, Excel, PowerPoint, and other document formats at scale. Triggers: "document translation", "batch translation", "translate documents", "DocumentTranslationClient".

Use this Skill: https://skilld.dev/gh/microsoft/skills/azure-ai-translation-document-py

This session only. Nothing lands on disk.

referencesnon-hero-scenarios.md

≈819 tokens on demand. Your agent reads this file only when SKILL.md points to it.

azure-ai-translation-document-py non-hero scenarios

These scenarios are intentionally separate from hero flows in SKILL.md. They cover secondary/advanced patterns typically used after the primary end-to-end path is working.

List Document Statuses

# Get status of individual documents in a job
operation_id = poller.id
document_statuses = client.list_document_statuses(operation_id)

for doc in document_statuses:
    print(f"Document: {doc.source_document_url}")
    print(f"  Status: {doc.status}")
    print(f"  Translated to: {doc.translated_to}")
    if doc.error:
        print(f"  Error: {doc.error.message}")

Cancel Translation

# Cancel a running translation
client.cancel_translation(operation_id)

Using Glossary

from azure.ai.translation.document import TranslationGlossary

poller = client.begin_translation(
    inputs=[
        DocumentTranslationInput(
            source_url=source_url,
            targets=[
                TranslationTarget(
                    target_url=target_url,
                    language="es",
                    glossaries=[
                        TranslationGlossary(
                            glossary_url="https://<storage>.blob.core.windows.net/glossary/terms.csv?<sas>",
                            file_format="csv"
                        )
                    ]
                )
            ]
        )
    ]
)

Supported Document Formats

# Get supported formats
formats = client.get_supported_document_formats()

for fmt in formats:
    print(f"Format: {fmt.format}")
    print(f"  Extensions: {fmt.file_extensions}")
    print(f"  Content types: {fmt.content_types}")

Supported Languages

DocumentTranslationClient does not expose a language discovery method. Use TextTranslationClient from azure-ai-translation-text instead — its get_supported_languages() call requires no authentication:

from azure.ai.translation.text import TextTranslationClient

# Languages endpoint requires no credential; default endpoint is https://api.cognitive.microsofttranslator.com
text_client = TextTranslationClient()  # no credential needed for this call
result = text_client.get_supported_languages()

# result.translation is a dict: BCP 47 code -> TranslationLanguage
for code, lang in result.translation.items():
    print(f"Language: {lang.name} ({code})")

Async Client

from azure.ai.translation.document.aio import DocumentTranslationClient
from azure.identity.aio import DefaultAzureCredential

async def translate_documents():
    async with DefaultAzureCredential() as credential:
        async with DocumentTranslationClient(
            endpoint=endpoint,
            credential=credential,
        ) as client:
            poller = await client.begin_translation(inputs=[...])
            result = await poller.result()

Supported Formats

Category Formats
Documents DOCX, PDF, PPTX, XLSX, HTML, TXT, RTF
Structured CSV, TSV, JSON, XML
Localization XLIFF, XLF, MHTML

Storage Requirements

  • Source and target containers must be Azure Blob Storage
  • Use SAS tokens with appropriate permissions:
    • Source: Read, List
    • Target: Write, List

Source: SKILL.md on GitHub

1 warning15d4 checks · Risk SAFE
  • Gen Agent Trust Hub15d

    This skill is safe for use. It utilizes official Azure AI SDKs and follows established security best practices for authentication and resource management.

  • Socket15d

    No alerts

  • Snyk15d

    Risk: LOW · No issues

  • Runlayer7mo

    2/2 files flagged

Signed by skilld at 4a2873f. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub yesterday.

Activeupdated 2 months ago
Other metadata
metadata
{
  "author": "Microsoft",
  "version": "1.0.0",
  "package": "azure-ai-translation-document"
}

README badge

README badge for microsoft/skills/azure-ai-translation-document-py