i18n-tools
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@i18n-toolstranslate 'Good morning' to French"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
@yyc3/i18n-core
๐ YYCยณ Production-Ready Internationalization Framework
้ซๆง่ฝใๆไปถๅใ้ถไพ่ต็ i18n ่งฃๅณๆนๆก๏ผไธไธบ็ฐไปฃ Web ๅบ็จ่ฎพ่ฎก
ๅพฝ็ซ ๆฐๆฎๅฃๅพ๏ผtests / coverage ๅ่ช CI
test:coverageๅฎ่ฏ๏ผ2026-09-26๏ผ30 files / 621 tests / 92.04% stmts๏ผ๏ผaudit ไธบไธๅทฅไฝๅบ้ถๆผๆดๅฎ่ฏใๅพฝ็ซ ่ฏญไนไธๅ จ็ซๅพๆ ่ง่่งใๅพฝ็ซ ไธๅพๆ ๅฏ่งๅไฝ็ณปใใ
๐ ๆฆ่ฟฐ
@yyc3/i18n-core ๆฏ YYCยณ๏ผYanYuCloudCube๏ผๆบ่ฝๅบ็จ้พไธญ็ๅฝ้ ๅๅบ็ก่ฎพๆฝๅฑ๏ผไธบๆดไธช็ๆๆไพๅค่ฏญ่จใAI็ฟป่ฏใMCPๅ่ฎฎ้ๆ่ฝๅใๅฎไธไป ๆฏไธไธช็ฌ็ซ็ i18n ๆกๆถ๏ผๆดๆฏ YYCยณ ็ๆใไบ้ซไบๆ ไบๅไบ็ปดใๆ ธๅฟ็ๅฟตๅจๅฝ้ ๅ้ขๅ็ๅ ทไฝ่ฝๅฐใ
ๅจ YYCยณ ็ๆไธญ็ๅฎไฝ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ YYCยณ ๆบ่ฝๅบ็จ็ๆ โ
โ โ
โ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โ
โ โ YYCยณ-CLI โ โ YYCยณ-ฯยณ โ โ Family-PAI โ โ
โ โ ๆๆกฃ็ๆ โ โ ่ฎพ่ฎกๅทฅๅ
ท โ โ AIๅบ็จ้พ โ โ
โ โ ๅผๆ โ โ ็ปไปถๆไปถ โ โ โ โ
โ โโโโโโโโฌโโโโโโโ โโโโโโโโฌโโโโโโโ โโโโโโโโฌโโโโโโโ โ
โ โ โ โ โ
โ โโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโ โ
โ โ โ
โ โโโโโโโโผโโโโโโโ โ
โ โ @yyc3/i18n โ โ ๅฝๅ้กน็ฎ โ
โ โ -core โ โ
โ โโโโโโโโฌโโโโโโโ โ
โ โ โ
โ โโโโโโโโโโโโโโโผโโโโโโโโโโโโโโ โ
โ โผ โผ โผ โ
โ โโโโโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโโ โ
โ โ AI็ฟป่ฏๅผๆ โ โMCP Serverโ โICU็ผ่ฏๅจ โ โ
โ โ(OpenAI+ โ โ(AI Agent โ โ(10่ฏญ่จ+ โ โ
โ โ Ollama) โ โ ๅทฅๅ
ท้ๆ) โ โ RTLๆฏๆ) โ โ
โ โโโโโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโไธ YYCยณ-CLI ็่กๆฅ
YYCยณ-CLI ๆฏ YYCยณ ็ๆ็ๆๆกฃๅ
จ็ๅฝๅจๆ็ๆๅผๆ๏ผv2.0.0๏ผ๏ผ่ด่ดฃ้กน็ฎๅๅงๅใๆ ๅๅๆๆกฃ็ๆใDevOps่ฟ็ปดใ@yyc3/i18n-core ไธๅ
ถๅฝขๆไปฅไธๅๅ๏ผ
ๅๅๅบๆฏ | CLI ่่ดฃ | i18n-core ่่ดฃ |
้กน็ฎๅๅงๅ |
| ่ชๅจๆณจๅ ฅ i18n ้ ็ฝฎ๏ผlocales/ + ๅผๆๅฎไพ๏ผ |
ๅค่ฏญ่จๆๆกฃ | ็ๆ็ฌฆๅ YYCยณ ๆ ๅ็ๆๆกฃๆถๆ | ไธบ็ๆ็ๆๆกฃๆไพ 10 ่ฏญ่จ็ฟป่ฏๆฏๆ |
AI ่ต่ฝ | AI ้ฉฑๅจ็ๆๆกฃ/ไปฃ็ ็ๆ | AI ็ฟป่ฏๅผๆ๏ผOpenAI + Ollama๏ผๅค็จๅไธ AI ๅบ็ก่ฎพๆฝ |
MCP ๅ่ฎฎ | AI Agent ๅทฅๅ ท้พ็ผๆ | ๆไพ i18n MCP Server ไฝไธบ Agent ๅฏ่ฐ็จๅทฅๅ ท |
CI/CD ้ๆ | DevOps ๆตๆฐด็บฟ็ผๆ | ๆไพ |
ๆ ธๅฟไปทๅผไธปๅผ
็ปดๅบฆ | ไผ ็ป i18n ๆนๆก | @yyc3/i18n-core |
AI ็ฟป่ฏ | ้ๅคๆฅ SaaS / ๆๅจ็ฟป่ฏ | ๅ็้ๆ OpenAI + Ollama ๅๅผๆ |
AI ๅไฝ | ๆ AI Agent ๆฅๅฃ | ่กไธ้ฆไธช i18n MCP Server๏ผ7 ไธชๅทฅๅ ท๏ผ |
ไพ่ต้พ | 3-10 ไธช่ฟ่กๆถไพ่ต | ้ถไพ่ต โ ๆ ไพๅบ้พ้ฃ้ฉ |
ๅฎๅ จ | ๅบ็กๆญฃๅ | OWASP L4 ๅฎๅ จ็ฉ้ต๏ผReDoS้ฒๆค/ๅฏ้ฅ็ญๅผ/้็้ๅถ๏ผ |
็ๆ | ็ฌ็ซๅทฅๅ ท | YYCยณ ๆบ่ฝๅบ็จ้พๅ็็ปไปถ |
ๆ็ฅๆนๅ: ่ฏฆ่ง ่กไธๆๆฏ่ถๅฟๅๆไธๅ จ้พ่ทฏ่ฝๅฐๆนๆก โ MCPๅ่ฎฎ็ๆ็ๅ๏ผ15,382+ Server / 9700ไธSDKๆไธ่ฝฝ๏ผ๏ผi18n MCP Server ๅ ๆฏ<1%๏ผ@yyc3/i18n-core ๆญฃๅคไบ่ฟไธช่ๆตท่ต้็ๆ ธๅฟไฝ็ฝฎใ
Related MCP server: @langapi/mcp-server
๐ ็ฎๅฝ
โจ ็นๆงๆฆ่ง
๐ฏ ๆ ธๅฟไผๅฟ
็นๆง | ๆ่ฟฐ | ็ถๆ |
้ถไพ่ต่ฟ่กๆถ | ๆ ไปปไฝ็ไบงไพ่ต๏ผ็บฏ TypeScript ๅฎ็ฐ | โ |
10 ็ง่ฏญ่จๅ ็ฝฎ | en/zh-CN/zh-TW/ja/ko/fr/de/es/pt-BR/ar(RTL) | โ |
AI ็ฟป่ฏ้ๆ | OpenAI + Ollama ๆฌๅฐๆจกๅๆฏๆ | โ |
MCP ๅ่ฎฎๅ็ | AI Agent ๅทฅๅ ท้ๆ๏ผ7 ไธช i18n ๅทฅๅ ท | โ |
ICU MessageFormat | ๅฎๆดๅฎ็ฐ๏ผ12 ็ง่ฏญๆณ็ฑปๅ | โ |
RTL ๅ็ๆฏๆ | ้ฟๆไผฏ่ฏญ็ญ RTL ่ฏญ่จๅธๅฑ่ชๅจๅค็ | โ |
LRU ็ผๅญ็ณป็ป | <0.1ms ็ผๅญๅฝไธญๅๅบๆถ้ด | โ |
ๆไปถๅๆถๆ | ๅฏๆฉๅฑ็็ๅฝๅจๆ้ฉๅญ็ณป็ป | โ |
ไผไธ็บงๅฎๅ จ | OWASP L4 ๅฎๅ จๆ ๅ | โ |
๐ ไธไธปๆตๆนๆกๅฏนๆฏ
็นๆง | @yyc3/i18n-core | react-i18next | vue-i18n | typesafe-i18n |
ไพ่ตๆฐ้ | 0 | 3+ | 2+ | 0 |
ๆๅ ๅคงๅฐ | ~15KB | ~33KB | ~1.5MB | ~1KB |
AI ็ฟป่ฏ | โ ๅ ็ฝฎ | ๆไปถ | ๆไปถ | โ |
MCP ๅ่ฎฎ | โ ๅ ็ฝฎ | โ | โ | โ |
ICU MessageFormat | โ ๅฎๆด | ๆไปถ | ๅบ็ก | ๅบ็ก |
RTL ๆฏๆ | โ ๅ็ | ้ ็ฝฎ | ้ ็ฝฎ | โ |
ๅฎๅ จ็ญ็บง | OWASP L4 | ๅบ็ก | ๅบ็ก | โ |
ไธญๆไผๅ | 10 ่ฏญ่จ | ้ ็ฝฎ | ้ ็ฝฎ | ้ ็ฝฎ |
๐ค ไธบไปไน้ๆฉ @yyc3/i18n-core?
1๏ธโฃ ็ๆญฃ็้ถไพ่ต
npm install @yyc3/i18n-core
# ไป
ๆญคไธไธชๅ
๏ผๆ ๅ
ถไปไพ่ต2๏ธโฃ ๅผ็ฎฑๅณ็จ็ไธญๆๆฏๆ
import { i18n, t } from '@yyc3/i18n-core';
// 10 ็ง่ฏญ่จๅณๆถๅฏ็จ
await i18n.setLocale('zh-CN'); // ็ฎไฝไธญๆ
await i18n.setLocale('zh-TW'); // ็นไฝไธญๆ
await i18n.setLocale('ja'); // ๆฅ่ฏญ
await i18n.setLocale('ko'); // ้ฉ่ฏญ
// ... ๆดๅค3๏ธโฃ AI ่ต่ฝ็ฟป่ฏ
import { AIProviderManager, OpenAIProvider } from '@yyc3/i18n-core/ai';
const ai = new AIProviderManager();
ai.register(new OpenAIProvider({ apiKey: 'your-key' }));
const result = await ai.translate({
sourceText: 'Hello World',
sourceLocale: 'en',
targetLocale: 'zh-CN',
});
console.log(result.translatedText); // "ไฝ ๅฅฝไธ็"4๏ธโฃ MCP ๅ่ฎฎๅ็้ๆ
import { MCPServer, registerI18nTools, StdioTransport } from '@yyc3/i18n-core/mcp';
const server = new MCPServer({
name: 'i18n-tools',
version: '1.4.0',
transport: new StdioTransport(),
});
registerI18nTools(server);
await server.start();
// ็ฐๅจ Claude/Cursor ็ญ AI ๅทฅๅ
ทๅฏไปฅไฝฟ็จ i18n ๅ่ฝไบ๏ผ๐ฆ ๅฎ่ฃ ๆๅ
ๅ็ฝฎ่ฆๆฑ
Node.js >= 18.0.0๏ผ
package.jsonengines ๅฃฐๆ๏ผLTS ็ๆฌๆจ่๏ผTypeScript >= 5.0 (ๆจ่๏ผไฝไนๆฏๆ JavaScript)
ๅฎ่ฃ ๅฝไปค
# ไฝฟ็จ npm
npm install @yyc3/i18n-core
# ไฝฟ็จ pnpm (ๆจ่)
pnpm add @yyc3/i18n-core
# ไฝฟ็จ yarn
yarn add @yyc3/i18n-core้ช่ฏๅฎ่ฃ
import { i18n, t } from '@yyc3/i18n-core';
console.log(t('common.welcome')); // "Welcome"
console.log('โ
@yyc3/i18n-core ๅฎ่ฃ
ๆๅ');๐ ๅฟซ้ๅผๅง
1. ๆ็ฎไฝฟ็จ โ ้ถ้ ็ฝฎๅฏๅจ
import { i18n, t } from '@yyc3/i18n-core';
// ็ดๆฅไฝฟ็จ๏ผๆ ้้
็ฝฎ
t('common.welcome'); // "Welcome"
// ๅๆข่ฏญ่จ
await i18n.setLocale('zh-CN');
t('common.welcome'); // "ๆฌข่ฟ"2. ๅธฆๆไปถ็ๅฎๆด้ ็ฝฎ
import { i18n, t, I18nEngine } from '@yyc3/i18n-core';
import {
createConsoleLogger,
MissingKeyReporter,
PerformanceTracker,
} from '@yyc3/i18n-core/plugins';
// ๅๅปบๅผๆๅฎไพ๏ผๆ้ ๅณๅฏ็จ๏ผๆ init ๆญฅ้ชค๏ผ
const engine = new I18nEngine({
locale: 'en', // ๅๅง่ฏญ่จ
fallbackLocale: 'en',
cache: {
maxSize: 1000,
ttl: 3600000, // 1ๅฐๆถ
},
});
// ๆณจๅๆไปถ
engine.plugins.register(createConsoleLogger());
engine.plugins.register(new MissingKeyReporter().createPlugin());
engine.plugins.register(
new PerformanceTracker({ slowThreshold: 10 }).createPlugin()
);
// ๆณจๅ่ฏญ่จ่ตๆบๅนถๆฟๆดป
engine.registerTranslation('en', enBundle);
await engine.setLocale('en');
// ไฝฟ็จ
engine.t('greeting', { name: 'World' }); // "Hello, World!"3. React ้กน็ฎ้ๆ
// App.tsx
import { useEffect, useState } from 'react';
import { i18n, t } from '@yyc3/i18n-core';
function App() {
const [locale, setLocale] = useState('en');
useEffect(() => {
i18n.setLocale(locale);
}, [locale]);
return (
<div>
<h1>{t('app.title')}</h1>
<p>{t('greeting', { name: 'User' })}</p>
<select value={locale} onChange={(e) => setLocale(e.target.value)}>
<option value="en">English</option>
<option value="zh-CN">ไธญๆ</option>
<option value="ja">ๆฅๆฌ่ช</option>
</select>
</div>
);
}4. Vue ้กน็ฎ้ๆ
<template>
<div>
<h1>{{ $t('app.title') }}</h1>
<button @click="changeLocale('zh-CN')">ไธญๆ</button>
<button @click="changeLocale('en')">English</button>
</div>
</template>
<script setup lang="ts">
import { i18n, t } from '@yyc3/i18n-core';
import { ref } from 'vue';
const changeLocale = async (locale: string) => {
await i18n.setLocale(locale);
};
</script>5. Node.js / ๅ็ซฏไฝฟ็จ
// server.ts
import { I18nEngine } from '@yyc3/i18n-core';
const i18n = new I18nEngine({
locale: 'zh-CN',
});
export async function middleware(req, res, next) {
const locale = req.headers['accept-language']?.split(',')[0] || 'zh-CN';
await i18n.setLocale(locale);
req.t = (key: string, params?: Record<string, string>) => i18n.t(key, params);
next();
}
// ๅจ่ทฏ็ฑไธญไฝฟ็จ
app.get('/api/hello', (req, res) => {
res.json({ message: req.t('hello') });
});โ ๏ธ ๅนถๅ้็ฆป๏ผ
setLocaleๅๆข็ๆฏๅฎไพ็บงๅ จๅฑ็ถๆใไธ่ฟฐๅไพๆจกๅผๅจๅค่ฏญ่จๅนถๅ่ฏทๆฑไธไผไบ็ธไธฒ่ฏญ่จ๏ผ็ไบง็ฏๅข่ฏทไธบๆฏไธช่ฏทๆฑๅๅปบ็ฌ็ซๅผๆๅฎไพ๏ผๆไฝฟ็จAsyncLocalStorageๆ่ฏทๆฑ้็ฆปใ
๐๏ธ ๆถๆ่ฎพ่ฎก
ๅๅฑๆถๆ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Application Layer โ
โ (React / Vue / Angular / Node.js) โ
โโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Public API Layer โ
โ i18n / t / I18nEngine / PluginManager โ
โโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโ
โผ โผ โผ โผ
โโโโโโโโโโโโโ โโโโโโโโโโโโโ โโโโโโโโโโโโโ โโโโโโโโโโโโโ
โ Core โ โ Cache โ โ Plugins โ โ Formats โ
โ Engine โ โ LRU โ โ System โ โ ICU/MF โ
โโโโโโโฌโโโโโโ โโโโโโโฌโโโโโโ โโโโโโโฌโโโโโโ โโโโโโโฌโโโโโโ
โ โ โ โ
โโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโ
โผ โผ โผ โผ
โโโโโโโโโโโโโ โโโโโโโโโโโโโ โโโโโโโโโโโโโ โโโโโโโโโโโโโ
โ AI โ โ MCP โ โ Security โ โ RTL โ
โ Translationโ โ Server โ โ OWASP L4 โ โ Utils โ
โโโโโโโโโโโโโ โโโโโโโโโโโโโ โโโโโโโโโโโโโ โโโโโโโโโโโโโๆจกๅ่่ดฃ
ๆจกๅ | ๆไปถ่ทฏๅพ | ่่ดฃ | ๅคๆๅบฆ |
Core Engine |
| ็ฟป่ฏๅผๆใ่ฏญ่จๅๆขใๅๆฐๆๅผ | โญโญโญ |
Cache System |
| LRU ็ผๅญใTTL ่ฟๆใ็ป่ฎก | โญโญ |
Plugin System |
| ็ๅฝๅจๆ้ฉๅญใไบไปถ่ฎข้ | โญโญ |
ICU Engine |
| MessageFormat ่งฃๆไธ็ผ่ฏ | โญโญโญ |
AI Translation |
| LLM ็ฟป่ฏใ่ดจ้่ฏไผฐ | โญโญโญ |
MCP Server |
| ๅ่ฎฎๅฎ็ฐใๅทฅๅ ทๆณจๅ | โญโญโญ |
Security |
| ReDoS้ฒๆคใๆณจๅ ฅๆฃๆต | โญโญ |
RTL Utils |
| ๅธๅฑ้ๅใๆนๅๆฃๆต | โญ |
ๆฐๆฎๆต
็จๆท่ฐ็จ t(key, params)
โ
Plugin.beforeTranslate()
โ
Cache Lookup โ Hit? โ Return Cached Result
โ Miss
ICU Parser โ Parse Syntax Tree
โ
Formatter โ Interpolate Parameters
โ
Plugin.afterTranslate()
โ
Cache.Store(Result)
โ
Return Translated String๐ฆ ๆ ธๅฟๆจกๅ่ฏฆ่งฃ
1. Core Engine (@yyc3/i18n-core)
็ฟป่ฏๅผๆ็ๆ ธๅฟ๏ผๆไพๅฎๆด็ i18n ่ฝๅใ
import { I18nEngine, i18n, t } from '@yyc3/i18n-core';
// ๆนๅผ1: ไฝฟ็จๅ
จๅฑๅไพ (ๆจ่็ฎๅๅบๆฏ)
t('welcome'); // "Welcome"
t('greeting', { name: 'World' }); // "Hello, World!"
// ๆนๅผ2: ๅๅปบ็ฌ็ซๅฎไพ (ๆจ่ๅคๆๅบๆฏ)
const engine = new I18nEngine({
locale: 'en',
fallbackLocale: 'en',
debug: false,
});
// ๆณจๅ่ฏญ่จ่ตๆบ๏ผๅๆญฅ๏ผ
engine.registerTranslation('zh-CN', zhCNBundle);
// ๅๆข่ฏญ่จ
await engine.setLocale('zh-CN');
// ๆน้็ฟป่ฏ
const results = engine.batchTranslate(['key1', 'key2', 'key3']);
// ่ทๅ็ป่ฎกไฟกๆฏ
const stats = engine.getStats();
// ่ฎข้
่ฏญ่จๅๆด
const unsubscribe = engine.subscribe((locale) => {
console.log(`Locale changed to: ${locale}`);
});I18nEngineConfig ๆฅๅฃ
interface I18nEngineConfig {
locale?: Locale; // ๅๅง่ฏญ่จ
fallbackLocale?: Locale; // ๅ้่ฏญ่จ
debug?: boolean; // ่ฐ่ฏๆจกๅผ: false
cache?: {
maxSize?: number; // ๆๅคง็ผๅญๆก็ฎ(้ป่ฎค 1000)
ttl?: number; // ่ฟๆๆถ้ดๆฏซ็ง(้ป่ฎค 5 ๅ้)
};
onError?: (error: Error, context: { key: string; locale: Locale }) => void;
missingKeyHandler?: (key: string, locale: Locale) => string;
}2. Cache System (@yyc3/i18n-core/cache)
้ซๆง่ฝ LRU ็ผๅญ๏ผๆพ่ๆๅ็ฟป่ฏๆง่ฝใ
import { LRUCache } from '@yyc3/i18n-core/cache';
// ๅๅปบ็ผๅญๅฎไพ
const cache = new LRUCache<string, string>({
maxSize: 1000, // ๆๅคง็ผๅญๆก็ฎ
ttl: 3600000, // ่ฟๆๆถ้ด (1ๅฐๆถ)
});
// ๅญๅๆฐๆฎ
cache.set('key', 'value');
const value = cache.get('key'); // "value"
// ็ผๅญๆชๅฝไธญ
cache.get('nonexistent'); // undefined
// ่ทๅ็ป่ฎกไฟกๆฏ
const stats: CacheStats = cache.getStats();
console.log(stats.hits, stats.misses, stats.size);
// ๆๅจๆธ
็
cache.clear();
cache.delete('key');ๆง่ฝๆๆ
ๆไฝ | ๆถ้ดๅคๆๅบฆ | ๅนณๅ่ๆถ |
get() | O(1) | <0.1ms |
set() | O(1) | <0.1ms |
ๆน้ๆฅๆพ | O(n) | <1ms (100 keys) |
3. Plugin System (@yyc3/i18n-core/plugins)
ๅฏๆฉๅฑ็ๆไปถๆถๆ๏ผๆฏๆ็ๅฝๅจๆ้ฉๅญใ
import {
PluginManager,
createConsoleLogger,
MissingKeyReporter,
PerformanceTracker,
} from '@yyc3/i18n-core/plugins';
// ๆณจๅๅ
็ฝฎๆไปถ
i18n.plugins.register(createConsoleLogger());
i18n.plugins.register(new MissingKeyReporter().createPlugin());
i18n.plugins.register(new PerformanceTracker({ slowThreshold: 10 }).createPlugin());
// ่ชๅฎไนๆไปถ
i18n.plugins.register({
name: 'analytics-plugin',
beforeTranslate(key: string) {
console.log(`[Analytics] Translating: ${key}`);
// ่ฟๅ true ็ปง็ปญๆง่ก๏ผ่ฟๅ false ไธญๆญ
return true;
},
afterTranslate(result: string, key: string) {
console.log(`[Analytics] Result: ${result}`);
},
onLocaleChange(from: string, to: string) {
console.log(`[Analytics] Locale: ${from} -> ${to}`);
},
});
// ็งป้คๆไปถ
i18n.plugins.unregister('analytics-plugin');ๅ ็ฝฎๆไปถๅ่กจ
ๆไปถๅ | ็จ้ | ้ ็ฝฎ้กน |
ConsoleLogger | ๅผๅ่ฐ่ฏๆฅๅฟ |
|
MissingKeyReporter | ็ไบง็ฏๅข็ผบๅคฑ้ฎ็ๆง |
|
PerformanceTracker | ๆง่ฝๆๆ ๆถ้ |
|
4. ICU MessageFormat (@yyc3/i18n-core/browser)
ๅฎๆด็ ICU MessageFormat ๅฎ็ฐ๏ผๆฏๆๅคๆฐใ้ๆฉ็ญๅคๆ่ฏญๆณใ
import { ICUParser, ICUCompiler } from '@yyc3/i18n-core/browser';
// ่งฃๆ ICU ่ฏญๆณ๏ผparse ไธบๅฎไพๆนๆณ๏ผ่ฟๅ { ast, errors }๏ผ
const parsed = new ICUParser().parse('{count, plural, one {# item} other {# items}}');
// ็ผ่ฏๅนถๆธฒๆ๏ผlocale ไธๅๆฐๅจ compile ไธไธๆไธญไผ ๅ
ฅ๏ผ
const result = new ICUCompiler().compile(parsed.ast, {
locale: 'en',
params: { count: '5' },
});
console.log(result); // "5 items"
// ๅจๅผๆไธญ็ดๆฅไฝฟ็จ๏ผ่ชๅจๆฃๆต ICU ่ฏญๆณ๏ผๅๆฐๅผไธบๅญ็ฌฆไธฒ๏ผ
t('items_count', { count: '5' }); // ่ชๅจ่ทฏ็ฑๅฐ ICU ็ผ่ฏๅจๆฏๆ็ ICU ่ฏญๆณ
่ฏญๆณ็ฑปๅ | ็คบไพ | ่ฏดๆ |
Plural |
| ๅคๆฐ่งๅ |
Select |
| ๆกไปถ้ๆฉ |
SelectOrdinal |
| ๅบๆฐ่ฏ |
Number |
| ๆฐๅญๆ ผๅผๅ |
Date |
| ๆฅๆๆ ผๅผๅ |
Time |
| ๆถ้ดๆ ผๅผๅ |
Offset |
| ๅ็งป้ |
5. AI Translation (@yyc3/i18n-core/ai)
LLM ้ฉฑๅจ็ๆบ่ฝ็ฟป่ฏ๏ผๆฏๆ OpenAI ๅๆฌๅฐ Ollamaใ
import {
AIProviderManager,
OpenAIProvider,
OllamaProvider,
QualityEstimator,
} from '@yyc3/i18n-core/ai';
// ๅๅปบ AI ็ฎก็ๅจ
const ai = new AIProviderManager();
// ๆณจๅ OpenAI Provider
ai.register(new OpenAIProvider({
apiKey: process.env.OPENAI_API_KEY!,
model: 'gpt-4o-mini',
}));
// ๆๆณจๅ Ollama Provider (ๅ
่ดนๆฌๅฐๆจกๅ)
ai.register(new OllamaProvider({
baseUrl: 'http://localhost:11434',
model: 'qwen2.5:3b',
}));
// ๆง่ก็ฟป่ฏ
const result = await ai.translate({
sourceText: 'Hello World',
sourceLocale: 'en',
targetLocale: 'zh-CN',
context: 'UI label for welcome message',
});
console.log(result.translatedText); // "ไฝ ๅฅฝไธ็"
console.log(result.confidence); // 0.95
// ่ดจ้่ฏไผฐ
const qe = new QualityEstimator();
const quality = await qe.estimate({
sourceText: 'Hello World',
translatedText: 'ไฝ ๅฅฝไธ็',
sourceLocale: 'en',
targetLocale: 'zh-CN',
});
console.log(quality.score); // 0.98
console.log(quality.issues); // [] (ๆ ้ฎ้ข)ๆฏๆ็ AI Provider
Provider | ็ฑปๅ | ๆๆฌ | ๅปถ่ฟ | ้็จๅบๆฏ |
OpenAI | ไบ็ซฏ API | ๐ฐ๐ฐ | ไฝ (<2s) | ็ไบง็ฏๅข |
Ollama | ๆฌๅฐๆจกๅ | ๅ ่ดน | ไธญ (~3s) | ๅผๅ/็ฆป็บฟ |
6. MCP Server (@yyc3/i18n-core/mcp)
Model Context Protocol ๆๅก็ซฏ๏ผ่ฎฉ AI Agent ็ดๆฅไฝฟ็จ i18n ๅทฅๅ ทใ
import {
MCPServer,
registerI18nTools,
StdioTransport,
} from '@yyc3/i18n-core/mcp';
// ๅๅปบ MCP Server
const server = new MCPServer({
name: 'yyc3-i18n-tools',
version: '1.4.0',
transport: new StdioTransport(),
});
// ๆณจๅ 7 ไธช i18n ๅทฅๅ
ท
registerI18nTools(server);
// ๅฏๅจๆๅก
await server.start();
console.log('MCP Server running...');
// ๅฏ็จๅทฅๅ
ท:
// 1. search_translations - ๆ็ดข็ฟป่ฏ
// 2. add_translation_key - ๆทปๅ ็ฟป่ฏ้ฎ
// 3. translate_key - ็ฟป่ฏๅไธช้ฎ
// 4. check_missing_keys - ๆฃๆฅ็ผบๅคฑ้ฎ
// 5. get_locale_stats - ่ทๅ่ฏญ่จ็ป่ฎก
// 6. set_locale - ่ฎพ็ฝฎๅฝๅ่ฏญ่จ
// 7. quality_report - ็ฟป่ฏ่ดจ้ๆฅๅMCP ๅทฅๅ ท่ฏฆๆ
ๅทฅๅ ทๅ | ๅ่ฝ | ๅๆฐ |
| ๆ็ดข็ฟป่ฏๅ ๅฎน | query, locale, limit |
| ๆทปๅ ๆฐ็ฟป่ฏ้ฎ | key, translations |
| ็ฟป่ฏๆๅฎ้ฎ | key, targetLocale |
| ๆฃๆฅ็ผบๅคฑ็็ฟป่ฏ้ฎ | locale |
| ่ทๅ่ฏญ่จ็ป่ฎกไฟกๆฏ | - |
| ่ฎพ็ฝฎๅฝๅ่ฏญ่จ | locale |
| ็ๆ่ดจ้ๆฅๅ | locale |
7. RTL Support (@yyc3/i18n-core โ ๅ
็ฝฎ)
RTL (Right-to-Left) ่ฏญ่จ็ๅ็ๆฏๆใ
import {
isRTL,
setupDocumentDirection,
flipSpacing,
getAlignment,
createMirroredLayout,
} from '@yyc3/i18n-core';
// ๆฃๆตๆฏๅฆไธบ RTL ่ฏญ่จ
isRTL('ar'); // true
isRTL('he'); // true
isRTL('en'); // false
// ่ชๅจ่ฎพ็ฝฎๆๆกฃๆนๅ
setupDocumentDirection('ar');
// <html dir="rtl" lang="ar">
// CSS ๅฑๆง็ฟป่ฝฌ
flipSpacing({ marginLeft: 10, marginRight: 20 }, 'rtl');
// โ { marginLeft: 20, marginRight: 10 }
// ่ทๅๅฏน้ฝๆนๅผ
getAlignment('ltr'); // 'left'
getAlignment('rtl'); // 'right'
// ๅๅปบ้ๅๅธๅฑ
const layout = createMirroredLayout('rtl');
layout.mainAxis; // 'right'
layout.crossAxis; // 'left'ๆฏๆ็ RTL ่ฏญ่จ
่ฏญ่จ | ไปฃ็ | ๆนๅ |
้ฟๆไผฏ่ฏญ | ar | RTL |
ๅธไผฏๆฅ่ฏญ | he | RTL |
ๆณขๆฏ่ฏญ | fa | RTL |
ไนๅฐ้ฝ่ฏญ | ur | RTL |
๐ณ ๅญ่ทฏๅพๅฏผๅ ฅ๏ผTree Shaking๏ผ
ๆ้ๅผๅ ฅ๏ผๆ่ดไผๅๆๅ ไฝ็งฏ
// ๅ
จ้จๅ่ฝ (~15KB gzipped)
import { i18n, t, I18nEngine } from '@yyc3/i18n-core'
// ไป
็ผๅญ็ณป็ป (~3KB gzipped)
import { LRUCache } from '@yyc3/i18n-core/cache'
// ไป
ๆไปถ็ณป็ป (~4KB gzipped)
import { PluginManager, createConsoleLogger } from '@yyc3/i18n-core/plugins'
// ไป
ICU ๅผๆ (~5KB gzipped)
import { ICUParser, ICUCompiler } from '@yyc3/i18n-core/browser'
// ไป
AI ็ฟป่ฏ (~4KB gzipped)
import { AIProviderManager, OpenAIProvider } from '@yyc3/i18n-core/ai'
// ไป
MCP ๆๅก็ซฏ (~3KB gzipped)
import { MCPServer, registerI18nTools } from '@yyc3/i18n-core/mcp'ๅฏ็จๅญ่ทฏๅพ
ๅญ่ทฏๅพ | ๅคงๅฐไผฐ่ฎก(gzipped) | ๅฏผๅบๅ ๅฎน | ้็จๅบๆฏ |
| ~15KB | ๅ จ้จๅ่ฝ | ๅฐๅ้กน็ฎ / ๅฟซ้ๅๅ |
| ~3KB | LRU Cache ็ณป็ป | ้่ฆ้ซๆง่ฝ็ผๅญ |
| ~4KB | ๆไปถ็ฎก็ๅจ + ๅ ็ฝฎๆไปถ | ้่ฆๆฉๅฑๅ่ฝ |
| ~5KB | ICU ่งฃๆๅจ/็ผ่ฏๅจ | ๅคๆๆถๆฏๆ ผๅผ |
| ~4KB | AI ็ฟป่ฏ + ่ดจ้่ฏไผฐ | ้่ฆ LLM ็ฟป่ฏ |
| ~3KB | MCP Server + Transport | AI Agent ้ๆ |
ๆๅ ไฝ็งฏๅฏนๆฏ
ๅบๆฏ | ๆชไผๅ | Tree Shakingๅ | ่็
-------------------------|--------|----------------|------
ๅฎๆดๅฏผๅ
ฅ | 15KB | 15KB | -
ไป
็จ Core + Cache | 15KB | 8KB | 47%
ไป
็จ ICU ๅผๆ | 15KB | 5KB | 67%
ไป
็จ AI Translation | 15KB | 4KB | 73%
ไป
็จ MCP Server | 15KB | 3KB | 80%๐ API ๅ่
ๆ ธๅฟๅฏผๅบ
// ====== ไธปๅ
ฅๅฃ ======
import {
// Engine
I18nEngine, i18n, t,
// Cache
LRUCache,
type CacheConfig, type CacheStats,
// Plugins
PluginManager,
createConsoleLogger, MissingKeyReporter, PerformanceTracker,
type I18nContext, type I18nPlugin,
// Formatter
formatRelativeTime, interpolate, pluralize,
type TranslateParams,
// Locale Detection
detectSystemLocale, isChineseLocale, normalizeLocale,
type LocaleDetectionResult,
// RTL Utilities
isRTL, setupDocumentDirection, flipSpacing, getAlignment,
getDirection, getOppositeAlignment, mirrorPosition,
createMirroredLayout, transformClassForRTL,
type HorizontalAlignment, type TextDirection,
// Types
type Locale, type RTLLocale, type TranslationMap,
} from '@yyc3/i18n-core'
// ====== ๅญ่ทฏๅพๅฏผๅ
ฅ ======
// Cache
import { LRUCache } from '@yyc3/i18n-core/cache'
// Plugins
import { PluginManager, createConsoleLogger } from '@yyc3/i18n-core/plugins'
// ICU
import { ICUParser, ICUCompiler } from '@yyc3/i18n-core/browser'
// AI
import { AIProviderManager, OpenAIProvider, QualityEstimator } from '@yyc3/i18n-core/ai'
// MCP
import { MCPServer, registerI18nTools, StdioTransport } from '@yyc3/i18n-core/mcp'ๆ ธๅฟ API
t() โ ็ฟป่ฏๅฝๆฐ
function t(key: string, params?: TranslateParams): string;
// ๅบๆฌ็จๆณ
t('welcome'); // "Welcome"
// ๅๆฐๆๅผ
t('greeting', { name: 'World' }); // "Hello, World!"
// ๅตๅฅๅฏน่ฑก
t('user.profile.name'); // ไปๅตๅฅๅฏน่ฑก่ทๅ
// ICU ่ฏญๆณ๏ผ่ชๅจๆฃๆต๏ผๅๆฐๅผไธบๅญ็ฌฆไธฒ๏ผ
t('items', { count: '5' }); // "5 items"i18n โ ๅ
จๅฑๅไพ
// ๅ
จๅฑๅไพ๏ผๆ ้ๅๅปบๅฎไพ
const i18n: I18nEngine;
// ๆณจๅ่ฏญ่จ่ตๆบๅนถๅๆข่ฏญ่จ
i18n.registerTranslation('zh-CN', zhCN);
await i18n.setLocale('zh-CN');
// ่ทๅๅฝๅ่ฏญ่จ
i18n.getLocale(); // 'zh-CN'
// ๆน้็ฟป่ฏ
const results = i18n.batchTranslate(['k1', 'k2', 'k3']);
// ่ทๅ็ป่ฎก
const stats = i18n.getStats();
// ไบไปถ็ๅฌ๏ผ่ฟๅ้่ฎขๅฝๆฐ๏ผ
const unsubscribe = i18n.subscribe((locale) => {});I18nEngine โ ๅผๆ็ฑป
class I18nEngine {
constructor(config?: I18nEngineConfig);
// ่ฏญ่จ็ฎก็
getLocale(): Locale;
setLocale(locale: string): Promise<void>;
registerTranslation(locale: Locale, map: TranslationMap): void;
getTranslations(locale: Locale): TranslationMap | undefined;
// ็ฟป่ฏ
t(key: string, params?: TranslateParams): string;
batchTranslate(keys: string[]): Record<string, string>;
createNamespace(prefix: string): {
t(key: string, params?: Record<string, string>): string;
batchTranslate(keys: string[]): Record<string, string>;
getLocale(): Locale;
};
// ไบไปถไธ่ฟ็ปด
subscribe(callback: (locale: Locale) => void): () => void;
setDebug(enabled: boolean): void;
getStats(): EngineStats;
destroy(): Promise<void>;
// ๅญ็ณป็ป๏ผๅช่ฏป๏ผ
readonly cache: LRUCache<string>;
readonly plugins: PluginManager;
}๐ง ้ซ็บงๅ่ฝ
1. ๅฝๅ็ฉบ้ด (Namespaces)
import { i18n } from '@yyc3/i18n-core';
// createNamespace ๆฏๅผๆๅฎไพๆนๆณ๏ผ้็ฌ็ซๅฏผๅบ๏ผ
const userNS = i18n.createNamespace('user');
const productNS = i18n.createNamespace('product');
// ไฝฟ็จๅฝๅ็ฉบ้ด๏ผ่ชๅจๆผๆฅๅ็ผ๏ผ
userNS.t('profile.name'); // โ i18n.t('user.profile.name')
productNS.t('detail.title'); // โ i18n.t('product.detail.title')2. ่ฐ่ฏๆจกๅผ
const engine = new I18nEngine({ debug: true });
// ๆต่งๅจๆงๅถๅฐ่ฎฟ้ฎ
window.__i18n_debug__ = {
engine,
getCurrentState: () => ({
locale: engine.getLocale(),
cache: engine.cache.getStats(),
plugins: engine.plugins.list(),
}),
};
// ๅผๅๆถๆฅ็็ถๆ
console.log(window.__i18n_debug__.getCurrentState());3. ๅคๅฎไพๆฏๆ
import { I18nEngine } from '@yyc3/i18n-core';
// ๅๅปบๅคไธช็ฌ็ซๅฎไพ
const adminI18n = new I18nEngine({ locale: 'zh-CN' });
const userI18n = new I18nEngine({ locale: 'en' });
// ๅ่ช็ฌ็ซ่ฟ่ก
adminI18n.t('dashboard.title'); // ไธญๆ
userI18n.t('home.welcome'); // English4. ่ชๅฎไน้่ฏฏๅค็
const engine = new I18nEngine({
onError: (error) => {
// ๅ้ๅฐ้่ฏฏ่ฟฝ่ธชๆๅก
Sentry.captureException(error);
},
missingKeyHandler: (key) => {
console.warn(`[i18n] Missing key: ${key}`);
return `[MISSING: ${key}]`; // ่ฟๅๅ ไฝ็ฌฆ
},
});5. ๆง่ฝ็ๆง
import { PerformanceTracker } from '@yyc3/i18n-core/plugins';
const tracker = new PerformanceTracker({
slowThreshold: 10, // ๆ
ขๆฅ่ฏข้ๅผ (ms)
maxSlowEntries: 50,
samplingRate: 1, // ็ไบงๅปบ่ฎฎ 0.1
});
i18n.plugins.register(tracker.createPlugin());
// ่ทๅๆง่ฝๆๆ
tracker.getCacheHitRate(); // ็ผๅญๅฝไธญ็ (0-100)
tracker.getPercentile(95); // 95ๅไฝๅปถ่ฟ (ms)
tracker.generateReport(); // ๅฎๆดๆง่ฝๆฅๅ๐จ ๆไฝณๅฎ่ทต
โ ๆจ่ๅๆณ
ไฝฟ็จๅ จๅฑๅไพ่ฟ่ก็ฎๅ้กน็ฎ
import { i18n, t } from '@yyc3/i18n-core'; t('key'); // ็ฎๆดๆไบไฝฟ็จ็ฌ็ซๅฎไพ่ฟ่กๅคงๅ้กน็ฎ
const engine = new I18nEngine({ /* config */ });ๅฉ็จ Tree Shaking ๅๅฐไฝ็งฏ
import { ICUParser } from '@yyc3/i18n-core/icu'; // ไป ๅผๅ ฅๆ้ๆจกๅๅฏ็จ็ไบง็ฏๅขๆไปถ
if (process.env.NODE_ENV === 'production') { i18n.plugins.register(new MissingKeyReporter().createPlugin()); }็ปๅ AI ็ฟป่ฏๆๅๆ็
const ai = new AIProviderManager(); ai.register(new OllamaProvider()); // ๅ ่ดนๆฌๅฐ็ฟป่ฏ
โ ้ฟๅ ๅๆณ
ไธ่ฆๅจๅพช็ฏไธญ้ข็น่ฐ็จ
setLocale// โ ้่ฏฏ: ๆง่ฝ้ฎ้ข for (const item of items) { await i18n.setLocale(item.locale); } // โ ๆญฃ็กฎ: ๆน้ๅค็๏ผbatchTranslate ไธบๅๆญฅๆนๆณ๏ผ const translations = i18n.batchTranslate(keys);ไธ่ฆๅฟฝ็ฅ้่ฏฏๅค็
// โ ้่ฏฏ: ๅฏ่ฝๆๅผๅธธ t(userProvidedKey); // โ ๆญฃ็กฎ: ้ ็ฝฎ missingKeyHandler const engine = new I18nEngine({ missingKeyHandler: (key) => `[${key}]`, });ไธ่ฆๅจ็ไบง็ฏๅขๅผๅฏ debug ๆจกๅผ
// โ ้่ฏฏ: ๆณ้ฒๅ ้จไฟกๆฏ const engine = new I18nEngine({ debug: true }); // โ ๆญฃ็กฎ: ไป ๅผๅ็ฏๅข const engine = new I18nEngine({ debug: process.env.NODE_ENV === 'development', });
๐งช ๆต่ฏ่ฆ็
ๆต่ฏ็ฉ้ต
ๆจกๅ | ๆต่ฏๆไปถ | ็จไพๆฐ | ้่ฟ็ | ่ฆ็็ |
Core Engine | engine-v2.test.ts | 45 | 100% | 94% |
Cache | (ๅซๅจ engine tests) | 30 | 100% | 96% |
Plugins | plugins.test.ts | 25 | 100% | 91% |
Formatter | formatter.test.ts | 35 | 100% | 93% |
Detector | detector.test.ts | 20 | 100% | 89% |
RTL Utils | rtl-utils.test.ts | 28 | 100% | 92% |
Translate | translate.test.ts, translate-full.test.ts | 60 | 100% | 95% |
ICU Parser/Compiler | icu/parser-compiler.test.ts | 40 | 100% | 90% |
AI Providers | ai/providers.test.ts | 35 | 100% | 87% |
Quality Estimator | ai/quality-estimator.test.ts | 25 | 100% | 85% |
MCP Server | mcp/server.test.ts, mcp/i18n-tools.test.ts | 40 | 100% | 88% |
Security | security/*.test.ts | 30 | 100% | 93% |
Infrastructure | infra/*.test.ts | 30 | 100% | 90% |
ๆป่ฎก | 30 files | 621 | โ 100% | 92.04% |
่ฆ็็ไธบ CI
test:coverage่ฏญๅฅ่ฆ็็ๅฎ่ฏ๏ผv8 ่ฆ็็๏ผ2026-09-26๏ผใ
่ฟ่กๆต่ฏ
# ๅ
จ้ๆต่ฏ
pnpm test
# ็ๅฌๆจกๅผ (ๅผๅๆถ)
pnpm test:watch
# ่ฆ็็ๆฅๅ
pnpm test:coverage
# ๅไธชๆไปถ
pnpm test -- engine-v2.test.ts
# ๅน้
ๆต่ฏๅ
pnpm test -- -t "should translate with interpolation"โก ๆง่ฝๅบๅ
ๅๅบๆถ้ด (Node.js 20, M2 Mac)
ๆไฝ | ๅนณๅ่ๆถ | P99 ่ๆถ | QPS |
็ฎๅ็ฟป่ฏ (็ผๅญๅฝไธญ) | 0.02ms | 0.05ms | 50,000+ |
ๅธฆๅๆฐ็ฟป่ฏ | 0.05ms | 0.12ms | 20,000+ |
ICU ๅคๆฐ่งๅ | 0.15ms | 0.35ms | 6,500+ |
ๆน้็ฟป่ฏ (100 keys) | 8ms | 15ms | 12,000+ |
AI ็ฟป่ฏ (Ollama) | 1500ms | 3000ms | 0.67 |
AI ็ฟป่ฏ (OpenAI) | 800ms | 2000ms | 1.25 |
ๅ ๅญๅ ็จ
ๅบๆฏ | ๅ ๅญๅ ็จ | ่ฏดๆ |
็ฉบๅผๆ | ~2MB | ๅบ็กๅผ้ |
ๅ ่ฝฝ 1 ่ฏญ่จ | ~5MB | ๅซ็ฟป่ฏๆฐๆฎ |
ๅ ่ฝฝ 10 ่ฏญ่จ | ~25MB | ๅ จ้จๅ ็ฝฎ่ฏญ่จ |
็ผๅญ 10000 ๆก็ฎ | ~8MB | LRU Cache |
AI Provider | ~50MB | ๆจกๅๅ ่ฝฝ |
๐ก๏ธ ๅฎๅ จ็นๆง
OWASP Level 4 ๅฎๅ จๆ ๅ
ๅฎๅ จ็ปดๅบฆ | ๅฎ็ฐๆนๅผ | ็ถๆ |
ReDoS ้ฒๆค | ๅฎๅ จๆญฃๅ็ผ่ฏ๏ผ่ถ ๆถไธญๆญ | โ |
ๆถๅบๆปๅป้ฒๆค | ๅธธ้ๆถ้ดๅญ็ฌฆไธฒๆฏ่พ | โ |
่ทฏๅพ้ๅ้ฒๆค | ็ฎๅฝ้้ธๆฃๆตไธ้ปๆญข | โ |
ๆณจๅ ฅๆฃๆต | SQL/Command ๆณจๅ ฅๆจกๅผ่ฏๅซ | โ |
ๅ ๅฏ้ๆบๆฐ | ไฝฟ็จ crypto.randomBytes | โ |
ๅฎๅ จ็คบไพ
// ๅไปๆ นๅ
ฅๅฃๅฏผๅบ๏ผNode.js ็ฏๅข๏ผ
import {
compileSafeRegex,
safeEqualSecret,
isPathInside,
} from '@yyc3/i18n-core';
// ๅฎๅ
จ็ๆญฃๅ่กจ่พพๅผ็ผ่ฏ (้ฒ ReDoS)
const result = compileSafeRegex(/^[a-z]+$/);
if (!result.safe) throw new Error(result.reason);
// ๅธธ้ๆถ้ดๆฏ่พ (้ฒๆถๅบๆปๅป)
const isEqual = safeEqualSecret(tokenA, tokenB);
// ่ทฏๅพ้ๅ้ฒๆค
isPathInside(userPath, baseDir); // ่ถ็่ฟๅ falseโ ๅธธ่ง้ฎ้ข
Q1: ๅฆไฝๆทปๅ ่ชๅฎไน่ฏญ่จ๏ผ
import { i18n } from '@yyc3/i18n-core';
// ๆณจๅ่ชๅฎไน่ฏญ่จ่ตๆบ
i18n.registerTranslation('custom-LANG', {
welcome: 'ๆฌข่ฟ',
greeting: 'ไฝ ๅฅฝ๏ผ{name}๏ผ',
});
await i18n.setLocale('custom-LANG');Q2: ๅฆไฝๅจ SSR (ๆๅก็ซฏๆธฒๆ) ไธญไฝฟ็จ๏ผ
// Next.js ็คบไพ
import { I18nEngine } from '@yyc3/i18n-core';
export async function getServerSideProps(context) {
const engine = new I18nEngine({ locale: context.locale });
engine.registerTranslation(context.locale, localeBundle);
await engine.setLocale(context.locale);
return {
props: {
initialLocale: context.locale,
translations: engine.getTranslations(context.locale),
},
};
}Q3: ๅฆไฝๅค็ๅจๆ็ฟป่ฏ้ฎ๏ผ
// ไฝฟ็จ missingKeyHandler ๆฆๆชๆช็ฅ้ฎ
const engine = new I18nEngine({
missingKeyHandler: (key) => {
// ๅ้ๅฐ็ฟป่ฏๆๅกๆ่ฟๅ้ป่ฎคๅผ
logMissingKeyToServer(key);
return humanizeKey(key); // 'user.profile.name' โ 'User Profile Name'
},
});Q4: AI ็ฟป่ฏ็่ดจ้ๅฆไฝไฟ่ฏ๏ผ
import { QualityEstimator } from '@yyc3/i18n-core/ai';
const qe = new QualityEstimator();
const result = await qe.estimate({
sourceText: 'Hello',
translatedText: 'ไฝ ๅฅฝ',
sourceLocale: 'en',
targetLocale: 'zh-CN',
});
if (result.score > 0.9 && result.issues.length === 0) {
console.log('โ
็ฟป่ฏ่ดจ้ไผ็ง');
} else {
console.log('โ ๏ธ ้่ฆไบบๅทฅๅฎกๆ ธ:', result.issues);
}Q5: ๅฆไฝไธ็ฐๆ i18n ๆนๆก่ฟ็งป๏ผ
่ฏทๅ่่ฏฆ็ป็ ่ฟ็งปๆๅ๏ผๆถต็ไป react-i18nextใvue-i18n ็ญๆนๆก็ๅฎๆด่ฟ็งปๆญฅ้ชคใ
๐ ่ฟ็งปๆๅ
ไป v1.x ๅ็บงๅฐ v2.x
ไธป่ฆ Breaking Changes:
ๅ ๅๅๆด:
@yyc3/i18nโ@yyc3/i18n-core็ฑปๅ้ๅฝๅ:
I18nManagerโI18nEngineๆไปถๆฅๅฃๆดๆฐ: ๆฐๅขๅฟ ้็
nameๅฑๆง้ ็ฝฎๆ ผๅผ่ฐๆด: Cache ๅ Debug ้ ็ฝฎ็ปๆๅๅ
่ฏฆ็ป่ฟ็งปๆญฅ้ชค่ฏทๅ้ MIGRATION_GUIDE.mdใ
๐๏ธ ๅพฝ็ซ ไธๅพๆ ๅฏ่งๅไฝ็ณป
ๅ จไปๅบๆๆกฃ็ๅฏ่งๅ่ฏญ่จ้ตๅพช็ปไธ่ฏญไน๏ผไธไธชๅพๆ /ๅพฝ็ซ ๅชๆฟ่ฝฝไธ็งๅซไน๏ผ่ทจ READMEใdocs ๆๆกฃ็ซไธ CHANGELOG ไฟๆไธ่ดใ
ๅพฝ็ซ ไฝ็ณป๏ผๅ็ฑปๅๅฑ๏ผ
ๅฑ็บง | ๅพฝ็ซ | ๆฐๆฎๆบ | ๆดๆฐๆบๅถ |
โ ๆๅปบ็ถๆ๏ผๅจๆ๏ผ | CI ยท Deploy ยท Docs ็ซ็น | GitHub Actions / shields website API | ๆฏๆฌกๆจ้่ชๅจๅทๆฐ |
โก ๅๅธ็ๆ๏ผๅจๆ๏ผ | npm version ยท License ยท Node engines | npm registry | ๅ็่ชๅจๅทๆฐ |
โข ๅทฅ็จ่ดจ้๏ผ้ๆ้ๅฎ๏ผ | tests ยท coverage ยท audit | CI | ๅๆดๆถไบบๅทฅๅฏน้ฝ + ๆณจๆๅ่ฏๆฅๆ |
โฃ ่ฝๅๆ ่ฏ๏ผ้ๆ๏ผ | ้ถไพ่ต ยท OWASP L4 ยท 10 languages/RTL ยท TS/pnpm | ๆถๆไบๅฎ | ้ๅคง็ๆฌๆถๅคๆ ธ |
็ปดๆค่งๅ๏ผ้ๆๅพฝ็ซ ๅฟ ้กป่ฝๅฏนๅบๅฐไธๆกๅฏๅค็ฐ่ฏๆฎ๏ผCI ๆฅๅฟ / audit ่พๅบ๏ผ๏ผ่ฏๆฎ่ฟๆๅณๆดๆฐ๏ผ็ฆๆญข่ฃ ้ฅฐๆงๆฐๅญใ
็ซ ่ๅพๆ ่ง่๏ผREADME ไธๆๆกฃ็ซๅ ฑ็จ๏ผ
ๅพๆ | ่ฏญไน | ๅบ็จ็ซ ่ |
๐ | ๅฝ้ ๅ/ๅค่ฏญ่จ่ฝๅ | ๆฆ่ฟฐใ่ฏญ่จ็นๆง |
๐ | ็ฎๅฝๅฏผ่ช | ็ฎๅฝ |
โจ | ็นๆงๆป่ง | ็นๆงๆธ ๅ |
๐ค | ้ๅๅณ็ญ | ไธบไปไน้ๆฉ |
๐ฏ | ๆ ธๅฟไผๅฟ๏ผ | ็นๆงๆฆ่งๅ |
๐ | ๆจชๅๅฏนๆฏ๏ผ | ็นๆงๆฆ่งๅ |
๐ฆ | ๅฎ่ฃ ไธๅ ็ฎก็ | ๅฎ่ฃ ๆๅใๆ ธๅฟๆจกๅ |
๐ | ๅฟซ้ๅผๅง/ไธๆ | ๅฟซ้ๅผๅง |
๐๏ธ | ๆถๆไธๆๅปบ | ๆถๆ่ฎพ่ฎกใๆๅปบไธ CI |
๐ณ | Tree Shaking / ๆ้ๅ ่ฝฝ | ๅญ่ทฏๅพๅฏผๅ ฅ |
๐ | ๆๆกฃไธๆๅ | API ๅ่ |
๐ง | ้ซ็บง็จๆณ๏ผๆๆกฃ็ซ ่๏ผยท ไฟฎๅค๏ผCHANGELOG ๅ็ฑป๏ผ | ้ซ็บงๅ่ฝ + CHANGELOG |
๐จ | ๆไฝณๅฎ่ทต | ๆไฝณๅฎ่ทต |
๐งช | ๆต่ฏ | ๆต่ฏ่ฆ็ |
โก | ๆง่ฝ | ๆง่ฝๅบๅ/ไผๅ |
๐ก๏ธ | ๅฎๅ จ | ๅฎๅ จ็นๆง๏ผOWASP ็ฉ้ต๏ผ |
โ | FAQ | ๅธธ่ง้ฎ้ข |
๐ | ่ฟ็งป | ่ฟ็งปๆๅ |
๐๏ธ | ๅฏ่งๅ่ง่ | ๆฌ็ซ ่ |
๐ค | ็คพๅบๅไฝ | ่ดก็ฎๆๅ |
๐ | ๆณๅพ | License |
๐ง ๅฝๅ็ฉบ้ด่ฏดๆ๏ผ๐ง ๅๆถๆๅกไบไธคไธชไบไธๅฒ็ช็ๅฝๅ็ฉบ้ด โโ ๅจๆๆกฃ็ซ ่ๅพๆ ่ฏญๅขไธญ่กจ็คบใ้ซ็บงๅ่ฝใ๏ผๅจ CHANGELOG ๅ็ฑปๅพๆ ่ฏญๅขไธญ่กจ็คบใไฟฎๅคใใๅไธๅฝๅ็ฉบ้ดๅ ไธไธชๅพๆ ๅชๆฟ่ฝฝไธ็งๅซไน๏ผ่ทจๅฝๅ็ฉบ้ดๅค็จไธ่งไธบ่ฏญไนๅฒ็ชใ
CHANGELOG ๅ็ฑปๅพๆ
ๆไบคไธ CHANGELOG ๆก็ฎไฝฟ็จๅไธๅฅๅ็ฑปๅ็ผ๏ผไธ Keep a Changelog ่ฏญไนๅฏน้ฝ๏ผ
๐ ๅฎๅ
จ ยท ๐ง ไฟฎๅค ยท ๐๏ธ ๆๅปบไธ CI ยท ๐ ๆๆกฃ ยท โจ ๆฐๅข็นๆง
ๆๆกฃ็ซๅพๆ ๆถๆ
ๆๆกฃ็ซ๏ผi18n.yyc3.vip๏ผๆฒฟ็จไธ่ฟฐ emoji ่ฏญไน๏ผๅนถไปฅ VitePress ไพงๆ ๅ็ป = ๅพๆ ่ฏญไนๅ็ป ็ๆ ๅฐ็ป็ป๏ผๆๅ๏ผ๐ ๅฟซ้ๅผๅง โ ๐๏ธ ่ฟ้ถ๏ผโ API๏ผ๐ ๅ่๏ผโ ๅฎๅ
จ๏ผ๐ก๏ธ๏ผใ้กต้ข็บงๅพๆ ๅบ็ฐๅจไธ็บงๆ ้ขๅ็ผ๏ผๅฏผ่ช็บงๅพๆ ๅบ็ฐๅจๅ็ปๆ ็ญพ๏ผไธคๅฑไธๆทท็จใ
๐ค ่ดก็ฎๆๅ
ๆไปฌๆฌข่ฟ็คพๅบ่ดก็ฎ๏ผ่ฏท้ตๅพชไปฅไธๆต็จ๏ผ
Fork ๆฌไปๅบ
ๅๅปบ็นๆงๅๆฏ (
git checkout -b feature/amazing-feature)ๆไบคๆดๆน (
git commit -m 'Add amazing feature')ๆจ้ๅๆฏ (
git push origin feature/amazing-feature)ๅผๅฏ Pull Request
ๅผๅๆต็จ
# ๅ
้ไปๅบ
git clone git@github.com:YYC-Cube/YYC3-i18n-Core.git
cd YYC3-i18n-Core
# ๅฎ่ฃ
ไพ่ต๏ผpnpm 11๏ผๆ นๅทฅไฝๅบๅซ packages/i18n-react๏ผ
pnpm install
# ๅผๅๆจกๅผ(ๆ ธๅฟๅ
ๆๅปบ็ๅฌ)
pnpm build:watch
# ่ฟ่กๆต่ฏ
pnpm test
# ็ฑปๅๆฃๆฅ
pnpm typecheck
# ๆ ผๅผๅไปฃ็
pnpm formatไปฃ็ ่ง่
TypeScript strict mode
ไธบๅ ฌๅ ฑ API ๆทปๅ JSDoc ๆณจ้
ๆฐๅ่ฝๅฟ ้กปๅ ๅซๅฏนๅบๆต่ฏ
้ตๅพช OWASP ๅฎๅ จ็ผ็ ่ง่
๐ License
MIT ยฉ YYCยณ AI Team
YYCยณ AI Family โ ๅ ซไฝๆไบบๅAIๅฎถไบบ็ๆบ่ฝไธญๆข
ไบ้ซ ยท ไบๆ ยท ไบๅ ยท ไบ็ปด
ๆๆกฃ็ๆฌ: 2.4.2 | ๆๅๆดๆฐ: 2026-09-26
This server cannot be deployed
Maintenance
Related MCP Connectors
OCR, transcription, file extraction, and image generation for AI agents via MCP.
Read-only MCP tools for AI agent discovery, structured resources, and NIULAI information.
Web search, scraping, RAG answers with citations, and translation as MCP tools.
Your org's AI agents, tasks, runs, search, and brain files as MCP tools and resources.
Related MCP Servers
AlicenseAqualityAmaintenanceAI-powered localization platform. Translate text, search translation memory, and access style guides from any MCP-compatible AI tool.21202 PyPI1MIT- AlicenseAqualityCmaintenanceMCP server for AI-powered translation management in i18n projects, enabling automated locale detection, translation status checks, and sync via LangAPI.430 npm1MIT
- AlicenseNot gradedqualityDmaintenanceAn MCP server that lets AI agents read and write locale JSON translation files directly from the conversation without loading the whole catalog into context.8 npm1ISC
- AlicenseAqualityBmaintenanceMCP server for managing i18n translation files โ gives your AI agent full control over your app's translations without dumping entire locale files into context.15251 npm11MIT