mirror of
https://github.com/qingchencloud/clawpanel.git
synced 2026-05-07 04:12:43 +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
48 lines
1.5 KiB
JavaScript
48 lines
1.5 KiB
JavaScript
/**
|
|
* Generate vi/es/pt/ru/fr/de locale JSON files
|
|
* Base: en.json → apply translations → write {lang}.json
|
|
*/
|
|
const fs = require('fs')
|
|
const path = require('path')
|
|
|
|
const LOCALES = path.resolve(__dirname, '../src/locales')
|
|
const PATCHES = path.resolve(__dirname, 'translations')
|
|
const en = JSON.parse(fs.readFileSync(path.join(LOCALES, 'en.json'), 'utf8'))
|
|
|
|
const LANGS = ['vi', 'es', 'pt', 'ru', 'fr', 'de']
|
|
|
|
function clone(o) { return JSON.parse(JSON.stringify(o)) }
|
|
|
|
function loadPatches(dir) {
|
|
if (!fs.existsSync(dir)) return {}
|
|
const merged = {}
|
|
for (const f of fs.readdirSync(dir).filter(x => x.endsWith('.json'))) {
|
|
const mod = f.replace('.json', '')
|
|
merged[mod] = JSON.parse(fs.readFileSync(path.join(dir, f), 'utf8'))
|
|
}
|
|
return merged
|
|
}
|
|
|
|
function applyTranslations(target, dict) {
|
|
for (const [section, entries] of Object.entries(dict)) {
|
|
if (!target[section]) continue
|
|
for (const [key, val] of Object.entries(entries)) {
|
|
if (target[section][key] !== undefined) {
|
|
target[section][key] = val
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
for (const lang of LANGS) {
|
|
const result = clone(en)
|
|
const patchDir = path.join(PATCHES, lang)
|
|
const patches = loadPatches(patchDir)
|
|
applyTranslations(result, patches)
|
|
const outPath = path.join(LOCALES, `${lang}.json`)
|
|
fs.writeFileSync(outPath, JSON.stringify(result, null, 2) + '\n', 'utf8')
|
|
const patchCount = Object.keys(patches).length
|
|
console.log(`✓ ${lang}.json generated (${patchCount} patch modules applied)`)
|
|
}
|
|
console.log(' Missing keys fallback to English')
|