mirror of
https://github.com/ImranR98/Obtainium.git
synced 2025-08-19 05:00:21 +02:00
"Standardize" translation files
This commit is contained in:
20
assets/translations/standardize.js
Normal file
20
assets/translations/standardize.js
Normal file
@@ -0,0 +1,20 @@
|
||||
// Take one (hardcoded) translation file and ensure that all other translation files have the same keys in the same order
|
||||
|
||||
const fs = require('fs')
|
||||
|
||||
const translationsDir = __dirname
|
||||
const templateFile = `${translationsDir}/en.json`
|
||||
const otherFiles = fs.readdirSync(translationsDir).map(f => {
|
||||
return `${translationsDir}/${f}`}).filter(f => f.endsWith('.json') && f != templateFile)
|
||||
|
||||
const templateTranslation = require(templateFile)
|
||||
|
||||
otherFiles.forEach(file => {
|
||||
console.log(file)
|
||||
const thisTranslationOriginal = require(file)
|
||||
const thisTranslationNew = {}
|
||||
Object.keys(templateTranslation).forEach(k => {
|
||||
thisTranslationNew[k] = thisTranslationOriginal[k] || templateTranslation[k]
|
||||
})
|
||||
fs.writeFileSync(file, `${JSON.stringify(thisTranslationNew, null, ' ')}\n`)
|
||||
});
|
Reference in New Issue
Block a user