allinssl/frontend/packages/vue/vite/plugin/index.ts

28 lines
976 B
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

// 如果你想自定义翻译处理
import { Scanner, Translator, TranslationQueue, FileManager } from "./i18n";
async function customTranslation() {
const config = {
scanDirs: ["src"], // 需要扫描的目录
fileTypes: [".vue", ".tsx", ".jsx", ".ts", ".js"], // 支持的文件类型
targetLanguages: ["en", "zh"], // 目标语言
outputDir: "src/locales", // 输出目录
glmConfig: {
apiKey: "a160afdbea1644e68de5e5b014bea0f7.zZuSidvDSYOD7oJT", // 你的智谱 AI API 密钥
apiEndpoint: "https://open.bigmodel.cn/api/paas/v4/chat/completions", // 可选API 端点
},
};
const scanner = new Scanner(config);
const translator = new Translator(config);
const queue = new TranslationQueue();
const fileManager = new FileManager(config);
// 自定义扫描和翻译逻辑
const results = await scanner.scanFiles();
// ... 处理翻译
await fileManager.generateI18nFiles(queue.getAll());
}
customTranslation();