专为游戏内容定制的本地化方案,支持 UI 文本、剧情对话、配音脚本、营销素材等全场景翻译。Tailored localization for games — covering UI text, story dialogue, voice scripts, marketing materials, and more.
OkHttpClient client = new OkHttpClient();
String json = "{ \\"text\\": \\"The ancient dragon awakens from its thousand-year slumber.\\",\n \\"content_type\\": \\"story\\",\n \\"source_lang\\": \\"en\\",\n \\"target_langs\\": [\\"zh\\",\\"ja\\",\\"ko\\"],\n \\"genre\\": \\"rpg\\",\n \\"tone\\": \\"epic\\"\n }";
RequestBody body = RequestBody.create(json, MediaType.parse("application/json"));
Request request = new Request.Builder()
.url("https://api.itranslator.cc/v1/game/localization")
.header("Authorization", "Bearer " + token)
.post(body)
.build();
Response response = client.newCall(request).execute();
System.out.println(response.body().string());
响应示例
Response Example
{
"original": "The ancient dragon awakens from its thousand-year slumber.",
"translations": {
"zh": "远古巨龙从千年沉睡中苏醒。",
"ja": "古の龍が千年の眠りから覚める。",
"ko": "고대의 용이 천 년의 잠에서 깨어난다."
},
"content_type": "story",
"genre": "rpg",
"tone": "epic"
}
Unity / Unreal 集成
Unity / Unreal Integration
提供 Unity Package 和 Unreal Plugin,可直接在引擎内调用翻译接口。结合 Open SDK 实现一键多语言打包。Unity Package and Unreal Plugin available for in-engine translation. Combine with Open SDK for one-click multi-language builds.
// Unity C# 示例
using iTranslator.SDK;
var client = new FanyiClient("YOUR_OAUTH_TOKEN");
var result = await client.GameLocalization.TranslateAsync(
"Press Start to begin your adventure.",
sourceLang: "en",
targetLangs: new[] { "zh", "ja", "ko" },
contentType: "ui",
genre: "rpg"
);
错误码
Error Codes
HTTP Code
错误码
Error Code
说明
Description
200
0
成功
Success
400
1001
参数错误,请检查必填参数和参数格式
Invalid parameter; check required fields and format
400
1002
不支持的语言代码
Unsupported language code
401
2001
认证失败,Token 无效或已过期
Authentication failed; invalid or expired token
403
2003
无权限访问该资源
Access denied; insufficient permissions
413
3001
请求文本超出长度限制(最大 50,000 字符)
Text exceeds maximum length (50,000 chars)
429
4001
请求频率超限,请稍后重试
Rate limit exceeded; please retry later
500
5001
服务器内部错误,请重试或联系技术支持
Internal server error; retry or contact support
使用说明Notes
所有 API 请求均使用 HTTPS,建议开启 HTTP Keep-Alive 以提高性能。
All API requests use HTTPS; enable HTTP Keep-Alive for better performance.
请勿在客户端代码中暴露 Access Token,建议通过后端代理调用。
Do not expose your Access Token in client-side code; use a backend proxy.
推荐设置合理的超时时间(30 秒),并实现指数退避重试策略。
Set a reasonable timeout (30s) and implement exponential backoff for retries.