Files
Momento/memento-note/extension/scripts/build-extension-locales.mjs
Antigravity e881004c77
Some checks failed
CI / Lint, Test & Build (push) Failing after 1m7s
CI / Deploy production (on server) (push) Has been skipped
feat(insights): fix DBSCAN, Persian embeddings crash, D3 physics layouts, and D3 node not found runtime error
2026-05-24 18:57:33 +00:00

32 lines
1.1 KiB
JavaScript

#!/usr/bin/env node
/**
* Genere extension/_locales/<lang>/messages.json depuis i18n/translations.json
* Usage: node scripts/build-extension-locales.mjs
*/
import fs from 'fs'
import path from 'path'
import { fileURLToPath } from 'url'
const __dirname = path.dirname(fileURLToPath(import.meta.url))
const extRoot = path.resolve(__dirname, '..')
const srcPath = path.join(extRoot, 'i18n', 'translations.json')
const outRoot = path.join(extRoot, '_locales')
const { version, strings } = JSON.parse(fs.readFileSync(srcPath, 'utf8'))
const langs = Object.keys(strings)
for (const lang of langs) {
const dir = path.join(outRoot, lang)
fs.mkdirSync(dir, { recursive: true })
const messages = {}
for (const [key, def] of Object.entries(strings[lang])) {
const entry = { message: def.message.replace(/\{version\}/g, version) }
if (def.description) entry.description = def.description
if (def.placeholders) entry.placeholders = def.placeholders
messages[key] = entry
}
fs.writeFileSync(path.join(dir, 'messages.json'), JSON.stringify(messages, null, 2) + '\n')
}
console.log(`Generated ${langs.length} locales in ${outRoot}`)