diff --git a/custom-api_v2.md b/custom-api_v2.md index 1da0aff..c59aa36 100644 --- a/custom-api_v2.md +++ b/custom-api_v2.md @@ -204,3 +204,53 @@ async ({ res }) => { return { translations: [[res?.choices?.[0]?.message?.content || ""]] }; }; ``` + + +## 语言代码表及说明 + +Hook参数里面的语言含义说明: + +- `toLang`, `fromLang` 是本插件支持的标准语言代码 +- `to`, `from` 是转换后的适用于特定接口的语言代码 + +如果你的自定义接口与下面的标准语言代码不匹配,需要自行映射转换。 + +``` +["en", "English - English"], +["zh-CN", "Simplified Chinese - 简体中文"], +["zh-TW", "Traditional Chinese - 繁體中文"], +["ar", "Arabic - العربية"], +["bg", "Bulgarian - Български"], +["ca", "Catalan - Català"], +["hr", "Croatian - Hrvatski"], +["cs", "Czech - Čeština"], +["da", "Danish - Dansk"], +["nl", "Dutch - Nederlands"], +["fi", "Finnish - Suomi"], +["fr", "French - Français"], +["de", "German - Deutsch"], +["el", "Greek - Ελληνικά"], +["hi", "Hindi - हिन्दी"], +["hu", "Hungarian - Magyar"], +["id", "Indonesian - Indonesia"], +["it", "Italian - Italiano"], +["ja", "Japanese - 日本語"], +["ko", "Korean - 한국어"], +["ms", "Malay - Melayu"], +["mt", "Maltese - Malti"], +["nb", "Norwegian - Norsk Bokmål"], +["pl", "Polish - Polski"], +["pt", "Portuguese - Português"], +["ro", "Romanian - Română"], +["ru", "Russian - Русский"], +["sk", "Slovak - Slovenčina"], +["sl", "Slovenian - Slovenščina"], +["es", "Spanish - Español"], +["sv", "Swedish - Svenska"], +["ta", "Tamil - தமிழ்"], +["te", "Telugu - తెలుగు"], +["th", "Thai - ไทย"], +["tr", "Turkish - Türkçe"], +["uk", "Ukrainian - Українська"], +["vi", "Vietnamese - Tiếng Việt"], +``` diff --git a/src/config/i18n.js b/src/config/i18n.js index 42313e6..dcb549b 100644 --- a/src/config/i18n.js +++ b/src/config/i18n.js @@ -156,13 +156,13 @@ async (args, { url, body, headers, userMsg, method } = {}) => { const responsetHookHelperZH = `1、第一个参数包含如下字段:'res', ... 2、返回值必须是包含以下字段的对象: 'translations' - ('translations' 应为一个二维数组:[[译文, 源语言]]) + ('translations' 应为一个二维数组:[[译文, 原文语言]]) 3、如返回空值,则hook函数不会产生任何效果。 // 示例 async ({ res, ...args }) => { - const translations = [["你好", "zh"]]; - const modelMsg = ""; + const translations = [["你好", "en"]]; + const modelMsg = {}; // 用于AI上下文 return { translations, modelMsg }; }`; @@ -173,8 +173,8 @@ const responsetHookHelperEN = `1. The first parameter contains the following fie // Example async ({ res, ...args }) => { - const translations = [["你好", "zh"]]; - const modelMsg = ""; + const translations = [["你好", "en"]]; + const modelMsg = {}; // For AI context return { translations, modelMsg }; }`;