mirror of
https://github.com/qingchencloud/clawpanel.git
synced 2026-05-07 06:12:58 +08:00
i18n: - Add 9 new locale files (ja/ko/de/es/fr/pt/ru/vi/zh-TW) - Add multilingual README files for all 11 languages - Add locale helper, index, and modular translation system - Add translation generation scripts Website (docs/index.html): - Replace 公益AI接口 branding with 晴辰云AI接口 - Remove OpenClaw 独立安装包 promotion block - Update SEO meta tags (description, keywords, OG, Twitter, JSON-LD) - Add 11-language README links to footer - Update 元宝派 link to new URL Bug fixes: - fix(cron): delivery format mode:'push' → mode:'announce', remove invalid 'to' field (fixes #141) - fix(cron): allow single-channel users to select delivery channel - fix(cron): preserve delivery field in job state for editing - fix(models): add 'ollama' as recognized API type, prevent overwriting native ollama config (fixes #140) - fix(models): skip /v1 append for ollama native API baseUrl - fix(assistant): normalize 'google-generative-ai' consistently, add ollama hints - fix(version): use CLI path classification for source detection on Windows (fixes #139) - fix(version): default to 'official' instead of 'chinese' when source unknown - fix(version): reorder npm global package check based on active CLI
55 lines
1.8 KiB
JavaScript
55 lines
1.8 KiB
JavaScript
/**
|
|
* Generate ja.json and ko.json by applying translation dictionaries
|
|
* to the en.json structure. Missing translations fallback to English.
|
|
* Run: node scripts/gen-ja-ko.cjs
|
|
*/
|
|
const fs = require('fs')
|
|
const path = require('path')
|
|
|
|
const LOCALES = path.resolve(__dirname, '../src/locales')
|
|
const en = JSON.parse(fs.readFileSync(path.join(LOCALES, 'en.json'), 'utf8'))
|
|
|
|
// Deep clone helper
|
|
const clone = o => JSON.parse(JSON.stringify(o))
|
|
|
|
// Apply translation dict to target (mutates target)
|
|
function applyTranslations(target, dict) {
|
|
for (const [section, keys] of Object.entries(dict)) {
|
|
if (!target[section]) continue
|
|
for (const [key, val] of Object.entries(keys)) {
|
|
if (target[section][key] !== undefined && val) {
|
|
target[section][key] = val
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Load translation patches from separate files
|
|
const jaPatches = path.join(__dirname, 'translations', 'ja')
|
|
const koPatches = path.join(__dirname, 'translations', 'ko')
|
|
|
|
function loadPatches(dir) {
|
|
if (!fs.existsSync(dir)) return {}
|
|
const result = {}
|
|
for (const file of fs.readdirSync(dir).filter(f => f.endsWith('.json'))) {
|
|
const section = file.replace('.json', '')
|
|
result[section] = JSON.parse(fs.readFileSync(path.join(dir, file), 'utf8'))
|
|
}
|
|
return result
|
|
}
|
|
|
|
// Generate ja.json
|
|
const ja = clone(en)
|
|
applyTranslations(ja, loadPatches(jaPatches))
|
|
fs.writeFileSync(path.join(LOCALES, 'ja.json'), JSON.stringify(ja, null, 2) + '\n', 'utf8')
|
|
console.log('✓ ja.json generated')
|
|
|
|
// Generate ko.json
|
|
const ko = clone(en)
|
|
applyTranslations(ko, loadPatches(koPatches))
|
|
fs.writeFileSync(path.join(LOCALES, 'ko.json'), JSON.stringify(ko, null, 2) + '\n', 'utf8')
|
|
console.log('✓ ko.json generated')
|
|
|
|
console.log(' Translations applied from scripts/translations/{ja,ko}/*.json')
|
|
console.log(' Missing keys fallback to English')
|