Stricter formatting of translation files: sort general files by key

This commit is contained in:
Pieter Vander Vennet 2022-02-18 03:51:52 +01:00
parent d5904b1714
commit 2974f8638b
21 changed files with 4142 additions and 4124 deletions

View file

@ -274,11 +274,29 @@ function transformTranslation(obj: any, depth = 1) {
}
function sortKeys(o: object): object{
const keys = Object.keys(o)
keys.sort()
const nw = {}
for (const key of keys) {
const v = o[key]
if(typeof v === "object"){
nw[key] = sortKeys(v)
}else{
nw[key] = v
}
}
return nw
}
/**
* Formats the specified file, helps to prevent merge conflicts
* */
function formatFile(path) {
const contents = JSON.parse(readFileSync(path, "utf8"))
let contents = JSON.parse(readFileSync(path, "utf8"))
contents = sortKeys(contents)
writeFileSync(path, JSON.stringify(contents, null, " "))
}