mirror of
https://github.com/insin/control-panel-for-twitter.git
synced 2025-06-19 15:15:31 -04:00

- All page script settings are now stored in a single settings object - All other top-level config is for extension-internal settings - Renamed old settings which were marked with comments in types.d.ts Background script - Open welcome (new installs) or updated (v4 → v5) page post-install - Migrate v4 user settings to new v5 format on update Page script: - Removed userscript pragma - Renamed page script config variable to 'settings' Scripts: - Moved utility and script API functions to lib.js - Updated copy script to copy all *.mv*.* files in the root dir - Added a clean script and command to remove files which correspond to a *.mv*.* file
47 lines
1.2 KiB
JavaScript
47 lines
1.2 KiB
JavaScript
const fs = require('fs')
|
|
|
|
const {sortProperties} = require('./lib')
|
|
|
|
if (process.argv.some(arg => /^-h|--help$/.test(arg))) {
|
|
console.log(`
|
|
Updates ../_locales/**/messages.json with translations from ./scripts/translations.json
|
|
|
|
Where translations.json is in the format:
|
|
|
|
{
|
|
"exampleMessageLabel": {
|
|
"en": "English version",
|
|
"es": "Versión en español"
|
|
}
|
|
}
|
|
`.trim()
|
|
)
|
|
process.exit()
|
|
}
|
|
|
|
let translationsJson = JSON.parse(fs.readFileSync('./translations.json', 'utf-8'))
|
|
let localeMessagesJson = new Map()
|
|
|
|
for (let [messageProp, translations] of Object.entries(translationsJson)) {
|
|
for (let [localeCode, message] of Object.entries(translations)) {
|
|
if (!localeMessagesJson.has(localeCode)) {
|
|
localeMessagesJson.set(
|
|
localeCode,
|
|
JSON.parse(
|
|
fs.readFileSync(`../_locales/${localeCode}/messages.json`, 'utf-8')
|
|
)
|
|
)
|
|
}
|
|
let messagesJson = localeMessagesJson.get(localeCode)
|
|
messagesJson[messageProp] = {...messagesJson[messageProp], message}
|
|
}
|
|
}
|
|
|
|
for (let [localeCode, messagesJson] of localeMessagesJson.entries()) {
|
|
fs.writeFileSync(
|
|
`../_locales/${localeCode}/messages.json`,
|
|
JSON.stringify(sortProperties(messagesJson), null, 2),
|
|
'utf8'
|
|
)
|
|
}
|