UNPKG

i18n-translate-agent

Version:

An intelligent i18n translation agent powered by OpenAI, supporting automatic translation of JSON files with caching and progress tracking

38 lines (37 loc) 1.32 kB
import path from "path"; import { fileURLToPath } from "url"; import { dirname } from "path"; import { CwalletTranslate } from "../index.js"; const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); const translator = new CwalletTranslate({ // Cache file path for optimized re-runs cacheFileRootPath: path.resolve(__dirname, "../cache"), sourceLanguage: "en", // Source translation files path // Target languages to translate to languages: [ // "zh-TW", // Traditional Chinese "ar", ], // Output directory for translated files outputRootPath: path.resolve(__dirname, "./locales2"), // workspace/cashier-v2/public/locales fileRootPath: path.resolve(__dirname, "./locales"), // Fine-tune translation context for better accuracy fineTune: [ "We are blockchain developers", "This is a cryptocurrency wallet application", "Technical terms should be kept consistent", ], // Optional: Custom OpenAI configuration openaiClientConfig: { apiKey: "", baseURL: "https://openrouter.ai/api/v1", // Optional: custom endpoint }, // Optional: Custom chat completion parameters chatCompletionCreateParams: { model: "gpt-4o", }, }); translator.translate();