azure-ai-translation-text-py 是什么?
这个 Skill 指导 Python 应用调用 Azure Translator 的文本 API,支持多目标语言翻译、自动检测、转写、词典例句、句子边界以及 HTML/亵渎词处理选项。它不替代译文人工校对。
中文说明由本站依据来源整理;英文原文保留在页面下方。
怎么接入你的 Agent?
- 定位完整 Skill 目录
打开本项目来源,核对
SKILL.md及其引用的脚本和资料。 - 交给你正在用的 Agent
在下面选择客户端,展开并复制安装指令,让 Agent 读取来源后选择安装方式。
- 确认识别,再做具体任务
让 Agent 回报安装目录和识别到的名称
azure-ai-translation-text-py,然后按本页使用示例提供材料。
展开并复制给 Codex 的安装指令
安装并检查 azure-ai-translation-text-py
请在 Codex 的当前工作环境中安装并检查 azure-ai-translation-text-py 这个 Skill。
项目身份:microsoft/skills / azure-ai-translation-text-py
来源:https://github.com/microsoft/skills/blob/f03ec5392f7a0f3aca12af47477e92f1edf7b44c/.github/plugins/azure-sdk-python/skills/azure-ai-translation-text-py/SKILL.md
已定位的源文件:.github/plugins/azure-sdk-python/skills/azure-ai-translation-text-py/SKILL.md
1. 先阅读真实 SKILL.md 和它引用的必要文件,确认触发条件、安装方式、依赖与权限;尊重源文件要求的审批步骤。
2. 按当前客户端支持的方式安装完整 Skill 目录,保留已有配置,不只复制一段提示词。涉及缺失凭证、目标目录或权限时先列出缺项并向我确认。
3. 安装后回读实际目录、Skill 名称和识别结果,说明哪些步骤已完成,哪些只是文档检查,不得把安装成功当作任务已经实测。
4. 如来源提供了可安全验证的示例,在我提供所需输入后做一个最小任务;创建、修改、删除、部署或发送内容前,按源文件和我的授权执行。展开并复制给 Claude Code 的安装指令
安装并检查 azure-ai-translation-text-py
请在 Claude Code 的当前工作环境中安装并检查 azure-ai-translation-text-py 这个 Skill。
项目身份:microsoft/skills / azure-ai-translation-text-py
来源:https://github.com/microsoft/skills/blob/f03ec5392f7a0f3aca12af47477e92f1edf7b44c/.github/plugins/azure-sdk-python/skills/azure-ai-translation-text-py/SKILL.md
已定位的源文件:.github/plugins/azure-sdk-python/skills/azure-ai-translation-text-py/SKILL.md
1. 先阅读真实 SKILL.md 和它引用的必要文件,确认触发条件、安装方式、依赖与权限;尊重源文件要求的审批步骤。
2. 按当前客户端支持的方式安装完整 Skill 目录,保留已有配置,不只复制一段提示词。涉及缺失凭证、目标目录或权限时先列出缺项并向我确认。
3. 安装后回读实际目录、Skill 名称和识别结果,说明哪些步骤已完成,哪些只是文档检查,不得把安装成功当作任务已经实测。
4. 如来源提供了可安全验证的示例,在我提供所需输入后做一个最小任务;创建、修改、删除、部署或发送内容前,按源文件和我的授权执行。展开并复制给 Cursor 的安装指令
安装并检查 azure-ai-translation-text-py
请在 Cursor Agent 的当前工作环境中安装并检查 azure-ai-translation-text-py 这个 Skill。
项目身份:microsoft/skills / azure-ai-translation-text-py
来源:https://github.com/microsoft/skills/blob/f03ec5392f7a0f3aca12af47477e92f1edf7b44c/.github/plugins/azure-sdk-python/skills/azure-ai-translation-text-py/SKILL.md
已定位的源文件:.github/plugins/azure-sdk-python/skills/azure-ai-translation-text-py/SKILL.md
1. 先阅读真实 SKILL.md 和它引用的必要文件,确认触发条件、安装方式、依赖与权限;尊重源文件要求的审批步骤。
2. 按当前客户端支持的方式安装完整 Skill 目录,保留已有配置,不只复制一段提示词。涉及缺失凭证、目标目录或权限时先列出缺项并向我确认。
3. 安装后回读实际目录、Skill 名称和识别结果,说明哪些步骤已完成,哪些只是文档检查,不得把安装成功当作任务已经实测。
4. 如来源提供了可安全验证的示例,在我提供所需输入后做一个最小任务;创建、修改、删除、部署或发送内容前,按源文件和我的授权执行。展开并复制给 当前 Agent 的安装指令
安装并检查 azure-ai-translation-text-py
请在 当前 Agent 的当前工作环境中安装并检查 azure-ai-translation-text-py 这个 Skill。
项目身份:microsoft/skills / azure-ai-translation-text-py
来源:https://github.com/microsoft/skills/blob/f03ec5392f7a0f3aca12af47477e92f1edf7b44c/.github/plugins/azure-sdk-python/skills/azure-ai-translation-text-py/SKILL.md
已定位的源文件:.github/plugins/azure-sdk-python/skills/azure-ai-translation-text-py/SKILL.md
1. 先阅读真实 SKILL.md 和它引用的必要文件,确认触发条件、安装方式、依赖与权限;尊重源文件要求的审批步骤。
2. 按当前客户端支持的方式安装完整 Skill 目录,保留已有配置,不只复制一段提示词。涉及缺失凭证、目标目录或权限时先列出缺项并向我确认。
3. 安装后回读实际目录、Skill 名称和识别结果,说明哪些步骤已完成,哪些只是文档检查,不得把安装成功当作任务已经实测。
4. 如来源提供了可安全验证的示例,在我提供所需输入后做一个最小任务;创建、修改、删除、部署或发送内容前,按源文件和我的授权执行。装好以后,具体怎么用?
准备哪些材料
- 安装 azure-ai-translation-text。Entra 认证使用资源自定义子域名 endpoint;全局 endpoint 下的 API key 认证需配合 Translator region。
- 准备翻译资源凭据,并在代码中用环境变量获取;key 不要提交到仓库。
- 先确认目标操作的语言/脚本支持;源文批量上限示例为每次最多100条,仍应依据当前接口限制复核。
实际使用顺序
- 用 TextTranslationClient.translate 传 body 文本列表和 to 语言列表;已知源语言时使用 from_parameter。
- 检查每项结果的 detected_language 与 translations;一条输入可得到多个目标译文。
- 按任务调用 transliterate、lookup_dictionary_entries/examples 或 find_sentence_boundaries,不要将音译混同翻译。
- HTML 内容显式使用 text_type="html";亵渎词标记/删除选项根据产品规范决定,结果保存前验证语言对与文本格式。
从一个具体任务开始
本站根据源文件编写的使用示例,未在本站实际运行。示例中的文件由你提供。
复制一个具体任务
请用 azure-ai-translation-text-py 给 Python 服务写一段英语到简体中文和日语的双目标文本翻译草案,读取 AZURE_TRANSLATOR_ENDPOINT 配置并检查每个输出语言。不要发起在线翻译。得到多目标语言结果遍历代码;未产生真实译文。
使用条件与边界
- 机器翻译输出需人工验证人名、术语、语气、格式和安全含义。
- Entra认证与key认证endpoint配置不相同;把全局endpoint和token credential混用会认证失败。
- 源文各功能的语言组合可能不同;translate支持不代表 dictionary/transliterate 同样支持。
常见问题
为什么全局 endpoint 配 DefaultAzureCredential 不工作?
源文指出令牌认证要求资源自定义子域名。可准备该 endpoint,或按现有全局 endpoint 的 key+region 方式认证。
如何把 HTML 标签保留下来?
请求使用 text_type="html",并在译后校验标签结构;不要把 HTML 作为普通纯文本提交后期待自动保留。
来源原文与资料状态
- 源文件
- 已保存 SKILL.md,抓取于 2026-11-16T12:36:35.145Z
- 中文使用说明
- 已针对下方源文件版本整理用途、用法和常见问题
- 安装与任务测试
- 本站未执行安装或任务测试
- 来源复核
- 本页中文用法已对照保存版本的完整 SKILL.md 阅读整理
展开 SKILL.md 原文、章节与历史收录资料
.github/plugins/azure-sdk-python/skills/azure-ai-translation-text-py/SKILL.md · 抓取时间 2026-11-16T12:36:35.145Z
以下保留源文件的 description、章节及摘录,供核对中文说明;完整文件通过上方链接打开。
抓取成功不代表已完成安装或任务测试。
Azure AI Text Translation SDK for real-time text translation, transliteration, language detection, and dictionary lookup. Use for translating text content in applications. Triggers: "text translation", "translator", "translate text", "transliterate", "TextTranslationClient".
查看源文件章节 / Source sections
- 原文:Azure AI Text Translation SDK for Python
- 安装 / Installation
- 原文:Environment Variables
- 原文:Authentication & Lifecycle
- 原文:Legacy: API Key (existing keyed deployments)
- 原文:Basic Translation
- 原文:Translate to Multiple Languages
- 原文:Specify Source Language
- 原文:Language Detection
- 原文:Transliteration
- 原文:Dictionary Lookup
- 原文:Dictionary Examples
- 原文:Get Supported Languages
- 原文:Break Sentence
- 原文:Translation Options
- 原文:Async Client
- 原文:Client Methods
- 原文:Best Practices
- 原文:Reference Files
原文:Azure AI Text Translation SDK for Python
Client library for Azure AI Translator text translation service for real-time text translation, transliteration, and language operations.
安装 / Installation
```bash pip install azure-ai-translation-text ```
原文:Environment Variables
```bash AZURE_TRANSLATOR_ENDPOINT=https://<resource>.cognitiveservices.azure.com # Required for Entra ID auth (must be a custom subdomain endpoint) AZURE_TOKEN_CREDENTIALS=prod # Required only if DefaultAzureCredential is used in production # Only required for the legacy API-key auth path below: AZURE_TRANSLATOR_KEY=<your-api-key> AZURE_TRANSLATOR_REGION=<your-region> # e.g., eastus, westus2; required when authenticating with a key against the global endpoint ```
原文:Authentication & Lifecycle
> **🔑 Two rules apply to every code sample below:** > > 1. **Prefer `DefaultAzureCredential`.** It works locally (Azure CLI / VS Code / Developer CLI) and in Azure (managed identity, workload identity) with no code change. Avoid connection strings, account/API keys — they bypass Entra audit and rotation. > - Local dev: `DefaultAzureCredential` works as-is. > - Production: set `AZURE_TOKEN_CREDENTIALS=prod` (or `AZURE_TOKEN_CREDENTIALS=<specific_credential>`) to constrain the credential chain to production-safe credentials. > 2. **Wrap every client in a context manager** so HTTP transports, sockets, and token caches are released deterministically: > - Sync: `with <Client>(...) as client:` > - Async: `async with <Client>(...) as client:` **and** `async with DefaultAzureCredential() as credential:` (from `azure.identity.aio`) > > Snippets may abbreviate this setup, but production code should always follow both rules. ```python import os from azure.identity import DefaultAzureCredential, ManagedIdentityCredential from azure.ai.translation.text import TextTranslationClient # Local dev: DefaultAzureCredential. Production: set AZURE_TOKEN_CREDENTIALS=prod or AZURE_TOKEN_CREDENTIALS=<specific_credential> credential = DefaultAzureCredential(require_envvar=True) # Or use a specific credential directly in production: # See https://learn.microsoft.com/python/api/overview/azure/identity-readme?view=azure-python#credential-classes # credential = ManagedIdentityCredential() with TextTranslationClient( endpoint=os.environ["AZURE_TRANSLATOR_ENDPOINT"], credential=credential, ) as client: result = client.translate(body=["Hello, world!"], to=["es"]) ```
原文:Legacy: API Key (existing keyed deployments)
New code should use `DefaultAzureCredential` above. The Translator service has two specifics that make API-key auth still common in existing deployments: - **Token-credential auth requires a custom subdomain endpoint** (`https://<resource>.cognitiveservices.azure.com`). If you only have the global endpoint (`https://api.cognitive.microsofttranslator.com`), you must either provision a custom subdomain or stay on the key-based path until you do. - **Key + region** is the canonical setup against the global endpoint. The region is sent as the `Ocp-Apim-Subscription-Region` header and is required whenever you use a multi-service or global Translator key. ```python import os from azure.core.credentials import AzureKeyCredential from azure.ai.translation.text import TextTranslationClient # Key + region against the global endpoint (most common keyed setup) with TextTranslationClient( credential=AzureKeyCredential(os.environ["AZURE_TRANSLATOR_KEY"]), region=os.environ["AZURE_TRANSLATOR_REGION"], ) as client: result = client.translate(body=["Hello, world!"], to=["es"]) # Key against a custom subdomain endpoint (no region required) with TextTranslationClient( endpoint=os.environ["AZURE_TRANSLATOR_ENDPOINT"], credential=AzureKeyCredential(os.environ["AZURE_TRANSLATOR_KEY"]), ) as client: result = client.translate(body=["Hello, world!"], to=["es"]) ```
原文:Basic Translation
```python # Translate to a single language result = client.translate( body=["Hello, how are you?", "Welcome to Azure!"], to=["es"] # Spanish ) for item in result: for translation in item.translations: print(f"Translated: {translation.text}") print(f"Target language: {translation.to}") ```
文件 SHA256:d0560012981e8e97f68c2eb69a1ad0875ec87a4d9e1f5c59fc6366b1d78dae06
仓库许可证记录:MIT;skill-declaration-captured-not-interpreted,查看来源。
Azure AI Text Translation SDK for real-time text translation, transliteration, language detection, and dictionary lookup. Use for translating text content in applications. Triggers: "text translation", "translator", "translate text", "transliterate", "TextTranslationClient".
历史收录数据
| 来源仓库 | microsoft/skills |
|---|---|
| Skill源路径 | .github/plugins/azure-sdk-python/skills/azure-ai-translation-text-py/SKILL.md |
安装前请让使用的Agent先读取这个SKILL.md及其所在目录,确认依赖和所需权限。此页不生成未经来源验证的安装命令。
