惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
The Blog of Author Tim Ferriss
S
Securelist
D
Docker
The Register - Security
The Register - Security
GbyAI
GbyAI
Recorded Future
Recorded Future
Engineering at Meta
Engineering at Meta
Stack Overflow Blog
Stack Overflow Blog
云风的 BLOG
云风的 BLOG
P
Proofpoint News Feed
罗磊的独立博客
博客园 - 【当耐特】
F
Full Disclosure
WordPress大学
WordPress大学
腾讯CDC
小众软件
小众软件
大猫的无限游戏
大猫的无限游戏
D
DataBreaches.Net
SecWiki News
SecWiki News
L
Lohrmann on Cybersecurity
I
InfoQ
MyScale Blog
MyScale Blog
量子位
Cyberwarzone
Cyberwarzone
博客园 - 三生石上(FineUI控件)
The Hacker News
The Hacker News
F
Fortinet All Blogs
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Jina AI
Jina AI
博客园_首页
H
Help Net Security
K
Kaspersky official blog
酷 壳 – CoolShell
酷 壳 – CoolShell
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Webroot Blog
Webroot Blog
Blog — PlanetScale
Blog — PlanetScale
V
Vulnerabilities – Threatpost
Y
Y Combinator Blog
The Cloudflare Blog
P
Proofpoint News Feed
V
Visual Studio Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
T
Tailwind CSS Blog
爱范儿
爱范儿
P
Privacy International News Feed
Security Archives - TechRepublic
Security Archives - TechRepublic
The GitHub Blog
The GitHub Blog
C
Cybersecurity and Infrastructure Security Agency CISA
B
Blog RSS Feed

热衷于的博客

罅隙蓬茂 恰到好处的隔阂与自由 DeepSeek这样评价本博 迷上了写油猴脚本 本站支持IPV6访问 辞渡 · 译 愿与君共赏 快!免费CDN套上 岁序更新,马到成功 绽放1999年的烟花 退件如蛊:垃圾消息涌入 拾起消失在风里的明信片 红泥巴村:童年乌托邦 公网IP三步立马搞定 足迹 Footprint “我曾来过” 巷陌烟火里,藏着贵阳的魂 SEO收录邀请?陷阱 勿忘国耻,警钟长鸣
[技] “福瑞”翻译接口
热衷于 · 2026-06-20 · via 热衷于的博客

各美其美,美人之美,美美与共,天下大同

声明:接口来源雷鸣云开源项目 translate.js,为 Edge 浏览器未公开 API,禁止商用!


1. 接口总览

1.1 接口地址

https://edge.microsoft.com/translate/translatetext

1.2 完整 URL 拼接规则

在链接后拼接源语言、目标语言双参数,模板如下:

https://edge.microsoft.com/translate/translatetext?from=${from}&to=${to}

2. 请求规范

大多情况下,调不通接口是由于忽略了请求方式、请求头、请求体细节造成的,以下是拆解。

◇ 请求基础

  • 请求方法:POST
  • 请求头:Content-Type: application/json,JSON 格式数据
  • 请求体:传入字符串数组以实现多行文本批量翻译,单行文本也需要包裹为数组

◇ URL 参数说明

  1. from 源语言(需要翻译的原文语种)

zh-CHS(简体中文)、en(英文)、ru(俄语)、ja(日语)、ko(韩语)

  1. to 目标语言(需要转换成的语种)
  2. 请求体示例

若输入两行文本:hello、world,分割后请求体即传入数组:["hello","world"]

  1. 返回格式

该接囗返回数组内是对象,格式为 [{translations:[{text:"译文"}]}]


3. 核心代码

下面是较标准的 fetch 请求核心代码,基于原生 JS 写成,供参考:

// from:源语言编码  to:目标语言编码  lines:待翻译文本数组
const response=await fetch(`https://edge.microsoft.com/translate/translatetext?from=${from}&to=${to}`,{
  method:'POST', 
  headers:{'Content-Type':'application/json'}, 
  body:JSON.stringify(lines)
});
// 解析返回结果
const result = await response.json();
console.log("翻译结果:", result);
const textList = result.map(item => item.translations[0].text);
const output = textList.join('\n');
document.getElementById('outputText').value = output;

4. 迷你项目

以下是基于该接囗的 HTML 页面,供参考:

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>自制极简翻译小工具</title>
    <style>
        textarea{width:45%;height:180px;padding:10px;margin:10px;}
        button{padding:8px 20px;font-size:16px;cursor:pointer;}
    </style>
</head>
<body>
    <textarea id="inputText" placeholder="输入原文,支持多行文本">Hello World
Nice to meet you</textarea>
    <textarea id="outputText" placeholder="翻译结果自动展示" readonly></textarea>
    <br/>
    <button onclick="translateText()">一键开始翻译</button>

    <script>
        async function translateText(){
            const input = document.getElementById('inputText').value;
            const lines = input.split('\n');
            const from = 'en';
            const to = 'zh-CHS';
            try{
                const res = await fetch(`https://edge.microsoft.com/translate/translatetext?from=${from}&to=${to}`,{
                    method:'POST',
                    headers:{'Content-Type':'application/json'},
                    body:JSON.stringify(lines)
                });
                const data = await res.json();
                // 提取翻译文本,解决 [object Object] 问题
                const translateResult = data.map(item => item.translations[0].text).join('\n');
                document.getElementById('outputText').value = translateResult;
            }catch(err){
                alert('翻译失败');
                console.error(err);
            }
        }
    </script>
</body>
</html>

敲下 fetch 请求,拼接一行 URL 参数,语言壁垒被瞬间跨越:

英文的直白浪漫、俄语的厚重铿锵、日语的细腻温柔、中文的含蓄诗意,在一行接口请求之间相融。

每一种语言,都是一个民族千年文化的载体:

  • 中文一字藏千意,寥寥数语便有山河风月;
  • 英文直白热烈,擅长直白表达情绪与热爱;
  • 小语种里的风土人情,不一样的生活与信仰。

从前靠书本、靠人力跨越语言隔阂的笨挫已去,我们更便捷地打破文字的边界。

编程从来不止是冰冷的语法、接口和参数,它是桥梁,让不同的文字相遇,让不同的文化相拥。

一行行请求、一次次数据交互中,看见世界的多元与美好。

微不足道的在线工具,却也是数字世界里,一次温柔的跨文化相遇。


本期为炒冷饭,哈哈哈哈哈哈哈哈!