Skip to content

Commit

Permalink
Merge pull request #3584 from thematters/develop
Browse files Browse the repository at this point in the history
Release: v4.25.0
  • Loading branch information
robertu7 authored Jul 5, 2023
2 parents e187a52 + b5d1093 commit eac9a28
Show file tree
Hide file tree
Showing 78 changed files with 6,943 additions and 2,910 deletions.
46 changes: 46 additions & 0 deletions bin/i18nGenerate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
const fs = require('fs')

const sort = (o) => {
return Object.keys(o)
.sort()
.reduce((r, k) => ((r[k] = o[k]), r), {})
}

const generate = (source, target) => {
const newTarget = { ...target }

// Finding keys missing in target and copying them from source
for (let key in source) {
if (!target.hasOwnProperty(key)) {
newTarget[key] = source[key]
}
}

// Removing keys missing in source from target
for (let key in target) {
if (!source.hasOwnProperty(key)) {
delete newTarget[key]
}
}

return sort(newTarget)
}

// read source file
const source = JSON.parse(fs.readFileSync('./lang/default.json', 'utf8'))

// read target file
const locales = ['zh-Hant', 'zh-Hans', 'en']
const target = {}
for (let locale of locales) {
target[locale] = JSON.parse(fs.readFileSync(`./lang/${locale}.json`, 'utf8'))
}

// genearte new target file
for (let locale of locales) {
fs.writeFileSync(
`./lang/${locale}.json`,
JSON.stringify(generate(source, target[locale]), null, 2),
'utf8'
)
}
4 changes: 4 additions & 0 deletions lang/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -1099,6 +1099,10 @@
"defaultMessage": "Explore Matters",
"description": ""
},
"uclzDH": {
"defaultMessage": "{q}: {totalCount, plural, =0 {} one {} other {# Results}} - Matters Search",
"description": "src/views/Search/AggregateResults/Articles.tsx"
},
"uw32VR": {
"defaultMessage": "tutorial",
"description": ""
Expand Down
Loading

0 comments on commit eac9a28

Please sign in to comment.