连接器(MCP)48k · #3898
azure-ai-translation-ts
它能做什么
这个工具可以在不同语言之间翻译文本和文档。它还能识别文本所使用的语言,并把一种语言的书写形式转换为另一种(音译)。
适用场景
- ✓翻译收到的外语邮件。
- ✓把一份文档从一种语言转换成另一种语言。
- ✓确认一段未知文本使用的是什么语言。
技能链接
https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/azure-ai-translation-ts/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
请用这个技能帮我:https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/azure-ai-translation-ts/SKILL.md
阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
npx skills add sickn33/agentic-awesome-skills --skill azure-ai-translation-ts
下载 SKILL.md,放进智能体的技能文件夹。
curl -L https://raw.githubusercontent.com/sickn33/agentic-awesome-skills/main/plugins/agentic-awesome-skills-claude/skills/azure-ai-translation-ts/SKILL.md -o SKILL.md
可以这样问 AI
“把这段话翻译成西班牙语和法语:'The sun shines and the birds sing.'”
每周 5 个新技能,1 分钟读完。
工作原理
你提供文本和想要的目标语言。工具会调用一项在线服务完成翻译,并返回结果。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Azure Translation SDKs for TypeScript
Text and document translation with REST-style clients.
Installation
# Text translation
npm install @azure-rest/ai-translation-text @azure/identity
# Document translation
npm install @azure-rest/ai-translation-document @azure/identity
Environment Variables
TRANSLATOR_ENDPOINT=https://api.cognitive.microsofttranslator.com
TRANSLATOR_SUBSCRIPTION_KEY=<your-api-key>
TRANSLATOR_REGION=<your-region> # e.g., westus, eastus
Text Translation Client
Authentication
import TextTranslationClient, { TranslatorCredential } from "@azure-rest/ai-translation-text";
// API Key + Region
const credential: TranslatorCredential = {
key: process.env.TRANSLATOR_SUBSCRIPTION_KEY!,
region: process.env.TRANSLATOR_REGION!,
};
const client = TextTranslationClient(process.env.TRANSLATOR_ENDPOINT!, credential);
// Or just credential (uses global endpoint)
const client2 = TextTranslationClient(credential);
Translate Text
import TextTranslationClient, { isUnexpected } from "@azure-rest/ai-translation-text";
const response = await client.path("/translate").post({
body: {
inputs: [
{
text: "Hello, how are you?",
language: "en", // source (optional, auto-detect)
targets: [
{ language: "es" },
{ language: "fr" },
],
},
],
},
});
if (isUnexpected(response)) {
throw response.body.error;
}
for (const result of response.body.value) {
for (const translation of result.translations) {
console.log(`${translation.language}: ${translation.text}`);
}
}
Translate with Options
const response = await client.path("/translate").post({
body: {
inputs: [
{
text: "Hello world",
language: "en",
textType: "Plain", // or "Html"
targets: [
{
language: "de",
profanityAction: "NoAction", // "Marked" | "Deleted"
tone: "formal", // LLM-specific
},
],
},
],
},
});
Get Supported Languages
const response = await client.path("/languages").get();
if (isUnexpected(response)) {
throw response.body.error;
}
// Translation languages
for (const [code, lang] of Object.entries(response.body.translation || {})) {
console.log(`${code}: ${lang.name} (${lang.nativeName})`);
}
Transliterate
const response = await client.path("/transliterate").post({
body: { inputs: [{ text: "这是个测试" }] },
queryParameters: {
language: "zh-Hans",
fromScript: "Hans",
toScript: "Latn",
},
});
if (!isUnexpected(response)) {
for (const t of response.body.value) {
console.log(`${t.script}: ${t.text}`); // Latn: zhè shì gè cè shì
}
}
Detect Language
const response = await client.path("/detect").post({
body: { inputs: [{ text: "Bonjour le monde" }] },
});
if (!isUnexpected(response)) {
for (const result of response.body.value) {
console.log(`Language: ${result.language}, Score: ${result.score}`);
}
}
Document Translation Client
Authentication
import DocumentTranslationClient from "@azure-rest/ai-translation-document";
import { DefaultAzureCredential } from "@azure/identity";
const endpoint = "https://<translator>.cognitiveservices.azure.com";
// TokenCredential
const client = DocumentTranslationClient(endpoint, new DefaultAzureCredential());
// API Key
const client2 = DocumentTranslationClient(endpoint, { key: "<api-key>" });
Single Document Translation
import DocumentTranslationClient from "@azure-rest/ai-translation-document";
import { writeFile } from "node:fs/promises";
const response = await client.path("/document:translate").post({
queryParameters: {
targetLanguage: "es",
sourceLanguage: "en", // optional
},
contentType: "multipart/form-data",
body: [
{
name: "document",
body: "Hello, this is a test document.",
filename: "test.txt",
contentType: "text/plain",
},
],
}).asNodeStream();
if (response.status === "200") {
await writeFile("translated.txt", response.body);
}
Batch Document Translation
import { ContainerSASPermissions, BlobServiceClient } from "@azure/storage-blob";
// Generate SAS URLs for source and target containers
const sourceSas = await sourceContainer.generateSasUrl({
…
常见问题
可以翻译整份文档吗?
可以,这个工具支持翻译完整的文档,并保留原有格式。
工具能自动检测语言吗?
能。如果你不确定文本是什么语言,可以让工具帮你检测。
能把一种语言的书写形式转换成另一种吗?
可以,工具能把一种书写系统的文字转写成另一种,例如把中文转写成拉丁字母。
详情
热度
- GitHub 星标
- 48k
- 排名
- #3898
- 许可证
- MIT
- 更新时间
- 2026/10/15
评论
- …
同一仓库的更多技能
00-andruia-consultant
48k帮你的智能体启动或改进 AI 项目。它可以分析代码、推荐工具,并用西班牙语制定行动计划。
AI 与智能体智能体
007
48k让你的智能体执行安全审计和威胁建模。它有助于保护项目免受攻击和漏洞的威胁。
编程安全
10-andruia-skill-smith
48k帮你的智能体创建或改进 AI 工具。它可以定义工具的工作方式、编写文档,并验证其结构。
AI 与智能体智能体
20-andruia-niche-intelligence
48k让你的智能体创建某个特定行业的摘要。它有助于借助可靠的信息来源,了解项目的背景、规则、使用模式和风险。
写作与文档调研