[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill-59288d81-c52f-4c55-a43f-5a57f5f4cb0e":3,"$fG9Ay_i-n6oULqJ-6KDDwaPT_BrxaEsDy7V8eFBDNFRI":43},{"id":4,"title":5,"description":6,"categoryId":7,"moduleId":8,"tags":9,"prompt":10,"icon":11,"source":12,"sourceUrl":13,"authorId":14,"authorName":15,"isPublic":16,"stars":17,"runs":18,"createdAt":19,"updatedAt":19,"module":20,"category":27,"packages":34},"59288d81-c52f-4c55-a43f-5a57f5f4cb0e","azure-ai-translation-document-py","Azure AI文档翻译SDK，用于格式保留的批量文档翻译。适用于大规模翻译Word、PDF、Excel、PowerPoint等文档格式。","cat_prod_document","mod_productivity","sickn33,productivity","---\nname: azure-ai-translation-document-py\ndescription: 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.\nrisk: unknown\nsource: community\ndate_added: '2026-02-27'\n---\n\n# Azure AI Document Translation SDK for Python\n\nClient library for Azure AI Translator document translation service for batch document translation with format preservation.\n\n## Installation\n\n```bash\npip install azure-ai-translation-document\n```\n\n## Environment Variables\n\n```bash\nAZURE_DOCUMENT_TRANSLATION_ENDPOINT=https:\u002F\u002F\u003Cresource>.cognitiveservices.azure.com\nAZURE_DOCUMENT_TRANSLATION_KEY=\u003Cyour-api-key>  # If using API key\n\n# Storage for source and target documents\nAZURE_SOURCE_CONTAINER_URL=https:\u002F\u002F\u003Cstorage>.blob.core.windows.net\u002F\u003Ccontainer>?\u003Csas>\nAZURE_TARGET_CONTAINER_URL=https:\u002F\u002F\u003Cstorage>.blob.core.windows.net\u002F\u003Ccontainer>?\u003Csas>\n```\n\n## Authentication\n\n### API Key\n\n```python\nimport os\nfrom azure.ai.translation.document import DocumentTranslationClient\nfrom azure.core.credentials import AzureKeyCredential\n\nendpoint = os.environ[\"AZURE_DOCUMENT_TRANSLATION_ENDPOINT\"]\nkey = os.environ[\"AZURE_DOCUMENT_TRANSLATION_KEY\"]\n\nclient = DocumentTranslationClient(endpoint, AzureKeyCredential(key))\n```\n\n### Entra ID (Recommended)\n\n```python\nfrom azure.ai.translation.document import DocumentTranslationClient\nfrom azure.identity import DefaultAzureCredential\n\nclient = DocumentTranslationClient(\n    endpoint=os.environ[\"AZURE_DOCUMENT_TRANSLATION_ENDPOINT\"],\n    credential=DefaultAzureCredential()\n)\n```\n\n## Basic Document Translation\n\n```python\nfrom azure.ai.translation.document import DocumentTranslationInput, TranslationTarget\n\nsource_url = os.environ[\"AZURE_SOURCE_CONTAINER_URL\"]\ntarget_url = os.environ[\"AZURE_TARGET_CONTAINER_URL\"]\n\n# Start translation job\npoller = client.begin_translation(\n    inputs=[\n        DocumentTranslationInput(\n            source_url=source_url,\n            targets=[\n                TranslationTarget(\n                    target_url=target_url,\n                    language=\"es\"  # Translate to Spanish\n                )\n            ]\n        )\n    ]\n)\n\n# Wait for completion\nresult = poller.result()\n\nprint(f\"Status: {poller.status()}\")\nprint(f\"Documents translated: {poller.details.documents_succeeded_count}\")\nprint(f\"Documents failed: {poller.details.documents_failed_count}\")\n```\n\n## Multiple Target Languages\n\n```python\npoller = client.begin_translation(\n    inputs=[\n        DocumentTranslationInput(\n            source_url=source_url,\n            targets=[\n                TranslationTarget(target_url=target_url_es, language=\"es\"),\n                TranslationTarget(target_url=target_url_fr, language=\"fr\"),\n                TranslationTarget(target_url=target_url_de, language=\"de\")\n            ]\n        )\n    ]\n)\n```\n\n## Translate Single Document\n\n```python\nfrom azure.ai.translation.document import SingleDocumentTranslationClient\n\nsingle_client = SingleDocumentTranslationClient(endpoint, AzureKeyCredential(key))\n\nwith open(\"document.docx\", \"rb\") as f:\n    document_content = f.read()\n\nresult = single_client.translate(\n    body=document_content,\n    target_language=\"es\",\n    content_type=\"application\u002Fvnd.openxmlformats-officedocument.wordprocessingml.document\"\n)\n\n# Save translated document\nwith open(\"document_es.docx\", \"wb\") as f:\n    f.write(result)\n```\n\n## Check Translation Status\n\n```python\n# Get all translation operations\noperations = client.list_translation_statuses()\n\nfor op in operations:\n    print(f\"Operation ID: {op.id}\")\n    print(f\"Status: {op.status}\")\n    print(f\"Created: {op.created_on}\")\n    print(f\"Total documents: {op.documents_total_count}\")\n    print(f\"Succeeded: {op.documents_succeeded_count}\")\n    print(f\"Failed: {op.documents_failed_count}\")\n```\n\n## List Document Statuses\n\n```python\n# Get status of individual documents in a job\noperation_id = poller.id\ndocument_statuses = client.list_document_statuses(operation_id)\n\nfor doc in document_statuses:\n    print(f\"Document: {doc.source_document_url}\")\n    print(f\"  Status: {doc.status}\")\n    print(f\"  Translated to: {doc.translated_to}\")\n    if doc.error:\n        print(f\"  Error: {doc.error.message}\")\n```\n\n## Cancel Translation\n\n```python\n# Cancel a running translation\nclient.cancel_translation(operation_id)\n```\n\n## Using Glossary\n\n```python\nfrom azure.ai.translation.document import TranslationGlossary\n\npoller = client.begin_translation(\n    inputs=[\n        DocumentTranslationInput(\n            source_url=source_url,\n            targets=[\n                TranslationTarget(\n                    target_url=target_url,\n                    language=\"es\",\n                    glossaries=[\n                        TranslationGlossary(\n                            glossary_url=\"https:\u002F\u002F\u003Cstorage>.blob.core.windows.net\u002Fglossary\u002Fterms.csv?\u003Csas>\",\n                            file_format=\"csv\"\n                        )\n                    ]\n                )\n            ]\n        )\n    ]\n)\n```\n\n## Supported Document Formats\n\n```python\n# Get supported formats\nformats = client.get_supported_document_formats()\n\nfor fmt in formats:\n    print(f\"Format: {fmt.format}\")\n    print(f\"  Extensions: {fmt.file_extensions}\")\n    print(f\"  Content types: {fmt.content_types}\")\n```\n\n## Supported Languages\n\n```python\n# Get supported languages\nlanguages = client.get_supported_languages()\n\nfor lang in languages:\n    print(f\"Language: {lang.name} ({lang.code})\")\n```\n\n## Async Client\n\n```python\nfrom azure.ai.translation.document.aio import DocumentTranslationClient\nfrom azure.identity.aio import DefaultAzureCredential\n\nasync def translate_documents():\n    async with DocumentTranslationClient(\n        endpoint=endpoint,\n        credential=DefaultAzureCredential()\n    ) as client:\n        poller = await client.begin_translation(inputs=[...])\n        result = await poller.result()\n```\n\n## Supported Formats\n\n| Category | Formats |\n|----------|---------|\n| Documents | DOCX, PDF, PPTX, XLSX, HTML, TXT, RTF |\n| Structured | CSV, TSV, JSON, XML |\n| Localization | XLIFF, XLF, MHTML |\n\n## Storage Requirements\n\n- Source and target containers must be Azure Blob Storage\n- Use SAS tokens with appropriate permissions:\n  - Source: Read, List\n  - Target: Write, List\n\n## Best Practices\n\n1. **Use SAS tokens** with minimal required permissions\n2. **Monitor long-running operations** with `poller.status()`\n3. **Handle document-level errors** by iterating document statuses\n4. **Use glossaries** for domain-specific terminology\n5. **Separate target containers** for each language\n6. **Use async client** for multiple concurrent jobs\n7. **Check supported formats** before submitting documents\n\n## When to Use\nThis skill is applicable to execute the workflow or actions described in the overview.\n\n## Limitations\n- Use this skill only when the task clearly matches the scope described above.\n- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.\n- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.\n","","imported","https:\u002F\u002Fgithub.com\u002Fsickn33\u002Fantigravity-awesome-skills","user_system_seed","SkillOPIC",true,193,1526,"2026-05-16 13:05:28",{"id":8,"name":21,"slug":22,"icon":23,"description":24,"sort":25,"createdAt":26},"效率工具","productivity","mdi-lightning-bolt-outline","文档处理、数据分析、自动化工作流",4,"2026-05-16 12:53:40",{"id":7,"name":28,"slug":29,"icon":30,"description":31,"moduleId":8,"sort":32,"skillCount":33,"createdAt":26},"文档处理","document","mdi-file-document-outline","PDF\u002FWord\u002FExcel\u002FPPT 处理",1,23,[35],{"id":36,"skillId":4,"version":37,"fileName":38,"fileSize":39,"filePath":40,"fileHash":41,"manifest":42,"createdAt":19},"1b6d30cb-60fb-454f-91a2-9279b7d18f72","1.0.0","azure-ai-translation-document-py.zip",2397,"uploads\u002Fskills\u002F59288d81-c52f-4c55-a43f-5a57f5f4cb0e\u002Fazure-ai-translation-document-py.zip","3f130d932006eed705edd1bcc34f1b11e8d56c6199fd7e7983503f1f950f2e92","[{\"path\":\"SKILL.md\",\"isDirectory\":false,\"size\":7146}]",{"code":44,"message":45,"data":46},200,"success",{"items":47,"stats":48,"page":51},[],{"averageRating":49,"totalRatings":49,"ratingCounts":50},0,[49,49,49,49,49],{"limit":52,"offset":49,"hasMore":53,"nextOffset":52,"ratedOnly":16},15,false]