feat: multi-language interface (zh-CN/zh-TW/en/ja), multilingual offline changelog, settings robustness
i18n - shared/i18n: dependency-free t() with flat per-namespace dictionaries (common/settings/workspace/terminal/ssh/panels/main), zh-CN fallback - language picker in Settings -> System; antd ConfigProvider locale follows it - main process tracks the language too: tray menu, close prompt, ssh/sftp/ zmodem errors and the log TUI marker are translated; tray rebuilds on change changelog - CHANGELOG.md (zh-CN canonical) + .zh-TW/.en/.ja, bundled via ?raw and read per interface language with per-version fallback to zh-CN (no network) - sync-changelog.cjs merges RELEASE_NOTES[.<lang>].md per release; release.cjs refuses to publish without a zh-CN entry for the version settings robustness - closeAction 'ask' survives the sanitizer (was silently coerced to 'tray', which made the 'ask every time' option dead) - highlight rules are repaired instead of dropped: string priority, 0/1 enabled, missing fg colour; unknown fields preserved - load-time warnings are written to settings-warnings.log (deduped, capped) terminal/UI - configurable terminal toolbar: open working directory (default on), session log recording (off), open logs folder (off) - global shortcut field records key combos (modifier or F-key required) - input suggestions + command history default to off, with a one-time reset migration for existing installs - settings dialog scrolling fixed (antd v6 renamed the tabs container), theme gallery nested scrollbar removed, joined segmented pickers with readable selected-state text tests: settings-store.mjs (15 checks) added; commands-store.mjs updated for the new off-by-default history setting
This commit is contained in:
1 parent
34094d607b
commit
4c6a29ef28
82 files changed
+3342
-608
No files matched your search
+53
-30
@@ -1,39 +1,62 @@
|
||||
/* Merge RELEASE_NOTES.md into CHANGELOG.md as the section for the current
|
||||
package.json version. Idempotent: skips if the version is already present.
|
||||
Run BEFORE `npm run dist` — the changelog is bundled into the app.
|
||||
Usage: node scripts/sync-changelog.cjs */
|
||||
/* Merge per-language release notes into the matching CHANGELOG file as the
|
||||
section for the current package.json version. Idempotent: a version already
|
||||
present is skipped. Run BEFORE `npm run dist` — the changelogs are bundled
|
||||
into the app and shown per interface language.
|
||||
Usage: node scripts/sync-changelog.cjs
|
||||
|
||||
RELEASE_NOTES.md (Simplified Chinese) is required; the other three are
|
||||
optional — a version without a translation falls back to zh-CN in the UI. */
|
||||
const fs = require('node:fs')
|
||||
const path = require('node:path')
|
||||
|
||||
const ROOT = path.join(__dirname, '..')
|
||||
const pkgVersion = JSON.parse(fs.readFileSync(path.join(ROOT, 'package.json'), 'utf8')).version
|
||||
const notesPath = path.join(ROOT, 'RELEASE_NOTES.md')
|
||||
const changelogPath = path.join(ROOT, 'CHANGELOG.md')
|
||||
const HEADER = '# OpenTerminal 更新日志'
|
||||
|
||||
const notes = fs.readFileSync(notesPath, 'utf8')
|
||||
// Drop the notes' own leading title / `## vX` heading — the section heading
|
||||
// is constructed here so CHANGELOG stays uniform (`## vX.Y.Z - date`).
|
||||
.replace(/^#.*\n/gm, '')
|
||||
.replace(new RegExp(`^## v${pkgVersion}.*\\n`), '')
|
||||
.replace(/^\s+/, '')
|
||||
.trimEnd()
|
||||
const TARGETS = [
|
||||
{ notes: 'RELEASE_NOTES.md', changelog: 'CHANGELOG.md', header: '# OpenTerminal 更新日志', required: true },
|
||||
{ notes: 'RELEASE_NOTES.zh-TW.md', changelog: 'CHANGELOG.zh-TW.md', header: '# OpenTerminal 更新日誌' },
|
||||
{ notes: 'RELEASE_NOTES.en.md', changelog: 'CHANGELOG.en.md', header: '# OpenTerminal Changelog' },
|
||||
{ notes: 'RELEASE_NOTES.ja.md', changelog: 'CHANGELOG.ja.md', header: '# OpenTerminal 更新履歴' }
|
||||
]
|
||||
|
||||
if (!notes) {
|
||||
console.error('RELEASE_NOTES.md is empty — write release notes first')
|
||||
process.exit(1)
|
||||
const sync = ({ notes, changelog, header, required }) => {
|
||||
const notesPath = path.join(ROOT, notes)
|
||||
const changelogPath = path.join(ROOT, changelog)
|
||||
if (!fs.existsSync(notesPath)) {
|
||||
if (required) {
|
||||
console.error(`${notes} is missing — write the release notes first`)
|
||||
process.exit(1)
|
||||
}
|
||||
console.log(`${changelog}: no ${notes} — left unchanged`)
|
||||
return
|
||||
}
|
||||
|
||||
const body = fs
|
||||
.readFileSync(notesPath, 'utf8')
|
||||
// Drop the notes' own title / `## vX` heading: the section heading is built
|
||||
// here so every changelog stays uniform (`## vX.Y.Z - date`).
|
||||
.replace(/^#.*\n/gm, '')
|
||||
.replace(new RegExp(`^## v${pkgVersion}.*\\n`), '')
|
||||
.replace(/^\s+/, '')
|
||||
.trimEnd()
|
||||
|
||||
if (!body) {
|
||||
console.error(`${notes} is empty — write the release notes first`)
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
const existing = fs.existsSync(changelogPath) ? fs.readFileSync(changelogPath, 'utf8') : ''
|
||||
if (existing.includes(`## v${pkgVersion} `)) {
|
||||
console.log(`${changelog}: already has v${pkgVersion} — nothing to do`)
|
||||
return
|
||||
}
|
||||
|
||||
const section = `## v${pkgVersion} - ${new Date().toISOString().slice(0, 10)}\n\n${body}\n`
|
||||
const updated = existing
|
||||
? existing.replace(new RegExp(`^(${header}\\n\\n)`), `$1${section}\n`)
|
||||
: `${header}\n\n${section}`
|
||||
fs.writeFileSync(changelogPath, updated, 'utf8')
|
||||
console.log(`${changelog}: added v${pkgVersion} (${body.split('\n').length} lines)`)
|
||||
}
|
||||
|
||||
const section = `## v${pkgVersion} - ${new Date().toISOString().slice(0, 10)}\n\n${notes}\n`
|
||||
const existing = fs.existsSync(changelogPath) ? fs.readFileSync(changelogPath, 'utf8') : ''
|
||||
if (existing.includes(`## v${pkgVersion} `)) {
|
||||
console.log(`CHANGELOG.md already has v${pkgVersion} — nothing to do`)
|
||||
process.exit(0)
|
||||
}
|
||||
|
||||
const updated = existing
|
||||
? existing.replace(new RegExp(`^(${HEADER}\\n\\n)`), `$1${section}\n`)
|
||||
: `${HEADER}\n\n${section}`
|
||||
|
||||
fs.writeFileSync(changelogPath, updated, 'utf8')
|
||||
console.log(`CHANGELOG.md: added v${pkgVersion} (${notes.split('\n').length} lines)`)
|
||||
for (const target of TARGETS) sync(target)
|
||||
Reference in new issue
Block a user