[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill-87b79168-66b1-44b1-8099-18154848392e":3,"$fxU06O1I8Mx3I6L76pt6fqxFvPtDh4mF2en3uL6X80rA":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},"87b79168-66b1-44b1-8099-18154848392e","azure-ai-translation-text-py","Azure AI文本翻译SDK，用于实时文本翻译、转写、语言检测和词典查询。用于在应用程序中翻译文本内容。","cat_coding_devops","mod_coding","sickn33,coding","---\nname: azure-ai-translation-text-py\ndescription: Azure AI Text Translation SDK for real-time text translation, transliteration, language detection, and dictionary lookup. Use for translating text content in applications.\nrisk: unknown\nsource: community\ndate_added: '2026-02-27'\n---\n\n# Azure AI Text Translation SDK for Python\n\nClient library for Azure AI Translator text translation service for real-time text translation, transliteration, and language operations.\n\n## Installation\n\n```bash\npip install azure-ai-translation-text\n```\n\n## Environment Variables\n\n```bash\nAZURE_TRANSLATOR_KEY=\u003Cyour-api-key>\nAZURE_TRANSLATOR_REGION=\u003Cyour-region>  # e.g., eastus, westus2\n# Or use custom endpoint\nAZURE_TRANSLATOR_ENDPOINT=https:\u002F\u002F\u003Cresource>.cognitiveservices.azure.com\n```\n\n## Authentication\n\n### API Key with Region\n\n```python\nimport os\nfrom azure.ai.translation.text import TextTranslationClient\nfrom azure.core.credentials import AzureKeyCredential\n\nkey = os.environ[\"AZURE_TRANSLATOR_KEY\"]\nregion = os.environ[\"AZURE_TRANSLATOR_REGION\"]\n\n# Create credential with region\ncredential = AzureKeyCredential(key)\nclient = TextTranslationClient(credential=credential, region=region)\n```\n\n### API Key with Custom Endpoint\n\n```python\nendpoint = os.environ[\"AZURE_TRANSLATOR_ENDPOINT\"]\n\nclient = TextTranslationClient(\n    credential=AzureKeyCredential(key),\n    endpoint=endpoint\n)\n```\n\n### Entra ID (Recommended)\n\n```python\nfrom azure.ai.translation.text import TextTranslationClient\nfrom azure.identity import DefaultAzureCredential\n\nclient = TextTranslationClient(\n    credential=DefaultAzureCredential(),\n    endpoint=os.environ[\"AZURE_TRANSLATOR_ENDPOINT\"]\n)\n```\n\n## Basic Translation\n\n```python\n# Translate to a single language\nresult = client.translate(\n    body=[\"Hello, how are you?\", \"Welcome to Azure!\"],\n    to=[\"es\"]  # Spanish\n)\n\nfor item in result:\n    for translation in item.translations:\n        print(f\"Translated: {translation.text}\")\n        print(f\"Target language: {translation.to}\")\n```\n\n## Translate to Multiple Languages\n\n```python\nresult = client.translate(\n    body=[\"Hello, world!\"],\n    to=[\"es\", \"fr\", \"de\", \"ja\"]  # Spanish, French, German, Japanese\n)\n\nfor item in result:\n    print(f\"Source: {item.detected_language.language if item.detected_language else 'unknown'}\")\n    for translation in item.translations:\n        print(f\"  {translation.to}: {translation.text}\")\n```\n\n## Specify Source Language\n\n```python\nresult = client.translate(\n    body=[\"Bonjour le monde\"],\n    from_parameter=\"fr\",  # Source is French\n    to=[\"en\", \"es\"]\n)\n```\n\n## Language Detection\n\n```python\nresult = client.translate(\n    body=[\"Hola, como estas?\"],\n    to=[\"en\"]\n)\n\nfor item in result:\n    if item.detected_language:\n        print(f\"Detected language: {item.detected_language.language}\")\n        print(f\"Confidence: {item.detected_language.score:.2f}\")\n```\n\n## Transliteration\n\nConvert text from one script to another:\n\n```python\nresult = client.transliterate(\n    body=[\"konnichiwa\"],\n    language=\"ja\",\n    from_script=\"Latn\",  # From Latin script\n    to_script=\"Jpan\"      # To Japanese script\n)\n\nfor item in result:\n    print(f\"Transliterated: {item.text}\")\n    print(f\"Script: {item.script}\")\n```\n\n## Dictionary Lookup\n\nFind alternate translations and definitions:\n\n```python\nresult = client.lookup_dictionary_entries(\n    body=[\"fly\"],\n    from_parameter=\"en\",\n    to=\"es\"\n)\n\nfor item in result:\n    print(f\"Source: {item.normalized_source} ({item.display_source})\")\n    for translation in item.translations:\n        print(f\"  Translation: {translation.normalized_target}\")\n        print(f\"  Part of speech: {translation.pos_tag}\")\n        print(f\"  Confidence: {translation.confidence:.2f}\")\n```\n\n## Dictionary Examples\n\nGet usage examples for translations:\n\n```python\nfrom azure.ai.translation.text.models import DictionaryExampleTextItem\n\nresult = client.lookup_dictionary_examples(\n    body=[DictionaryExampleTextItem(text=\"fly\", translation=\"volar\")],\n    from_parameter=\"en\",\n    to=\"es\"\n)\n\nfor item in result:\n    for example in item.examples:\n        print(f\"Source: {example.source_prefix}{example.source_term}{example.source_suffix}\")\n        print(f\"Target: {example.target_prefix}{example.target_term}{example.target_suffix}\")\n```\n\n## Get Supported Languages\n\n```python\n# Get all supported languages\nlanguages = client.get_supported_languages()\n\n# Translation languages\nprint(\"Translation languages:\")\nfor code, lang in languages.translation.items():\n    print(f\"  {code}: {lang.name} ({lang.native_name})\")\n\n# Transliteration languages\nprint(\"\\nTransliteration languages:\")\nfor code, lang in languages.transliteration.items():\n    print(f\"  {code}: {lang.name}\")\n    for script in lang.scripts:\n        print(f\"    {script.code} -> {[t.code for t in script.to_scripts]}\")\n\n# Dictionary languages\nprint(\"\\nDictionary languages:\")\nfor code, lang in languages.dictionary.items():\n    print(f\"  {code}: {lang.name}\")\n```\n\n## Break Sentence\n\nIdentify sentence boundaries:\n\n```python\nresult = client.find_sentence_boundaries(\n    body=[\"Hello! How are you? I hope you are well.\"],\n    language=\"en\"\n)\n\nfor item in result:\n    print(f\"Sentence lengths: {item.sent_len}\")\n```\n\n## Translation Options\n\n```python\nresult = client.translate(\n    body=[\"Hello, world!\"],\n    to=[\"de\"],\n    text_type=\"html\",           # \"plain\" or \"html\"\n    profanity_action=\"Marked\",  # \"NoAction\", \"Deleted\", \"Marked\"\n    profanity_marker=\"Asterisk\", # \"Asterisk\", \"Tag\"\n    include_alignment=True,      # Include word alignment\n    include_sentence_length=True # Include sentence boundaries\n)\n\nfor item in result:\n    translation = item.translations[0]\n    print(f\"Translated: {translation.text}\")\n    if translation.alignment:\n        print(f\"Alignment: {translation.alignment.proj}\")\n    if translation.sent_len:\n        print(f\"Sentence lengths: {translation.sent_len.src_sent_len}\")\n```\n\n## Async Client\n\n```python\nfrom azure.ai.translation.text.aio import TextTranslationClient\nfrom azure.core.credentials import AzureKeyCredential\n\nasync def translate_text():\n    async with TextTranslationClient(\n        credential=AzureKeyCredential(key),\n        region=region\n    ) as client:\n        result = await client.translate(\n            body=[\"Hello, world!\"],\n            to=[\"es\"]\n        )\n        print(result[0].translations[0].text)\n```\n\n## Client Methods\n\n| Method | Description |\n|--------|-------------|\n| `translate` | Translate text to one or more languages |\n| `transliterate` | Convert text between scripts |\n| `detect` | Detect language of text |\n| `find_sentence_boundaries` | Identify sentence boundaries |\n| `lookup_dictionary_entries` | Dictionary lookup for translations |\n| `lookup_dictionary_examples` | Get usage examples |\n| `get_supported_languages` | List supported languages |\n\n## Best Practices\n\n1. **Batch translations** — Send multiple texts in one request (up to 100)\n2. **Specify source language** when known to improve accuracy\n3. **Use async client** for high-throughput scenarios\n4. **Cache language list** — Supported languages don't change frequently\n5. **Handle profanity** appropriately for your application\n6. **Use html text_type** when translating HTML content\n7. **Include alignment** for applications needing word mapping\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,203,1743,"2026-05-16 13:05:31",{"id":8,"name":21,"slug":22,"icon":23,"description":24,"sort":25,"createdAt":26},"编程开发","coding","mdi-code-braces","代码生成、调试、审查，提升开发效率",2,"2026-05-16 12:53:40",{"id":7,"name":28,"slug":29,"icon":30,"description":31,"moduleId":8,"sort":32,"skillCount":33,"createdAt":26},"DevOps","devops","mdi-cog-outline","CI\u002FCD、容器化、部署运维",3,162,[35],{"id":36,"skillId":4,"version":37,"fileName":38,"fileSize":39,"filePath":40,"fileHash":41,"manifest":42,"createdAt":19},"5a531a37-a53d-4b0c-a402-42cee0753af2","1.0.0","azure-ai-translation-text-py.zip",2560,"uploads\u002Fskills\u002F87b79168-66b1-44b1-8099-18154848392e\u002Fazure-ai-translation-text-py.zip","7634ac052ef6414116c7b767d858502d968352155e468e9fa83b70fac620b8ea","[{\"path\":\"SKILL.md\",\"isDirectory\":false,\"size\":7698}]",{"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]