Merge develop

This commit is contained in:
Pieter Vander Vennet 2022-02-18 03:53:15 +01:00
commit 1103f8f157
54 changed files with 4629 additions and 4850 deletions

View file

@ -55,11 +55,11 @@ function main() {
args.splice(0, 2)
const path = args[0]
const iconClass = args[1] ?? "small"
console.log("Fixing images in " + path)
const targetFile = args[2] ?? path + ".autoconverted.json"
const parsed = JSON.parse(readFileSync(path, "UTF8"))
const converted = new ConvertImagesToIcon(iconClass).convertStrict(parsed, "While running the fixImagesInTagRenderings-script")
writeFileSync(path + ".autoconverted.json", JSON.stringify(converted, null, " "))
console.log("Written fixed version to " + path + ".autoconverted.json")
writeFileSync(targetFile, JSON.stringify(converted, null, " "))
console.log("Written fixed version to " + targetFile)
}
main();

View file

@ -0,0 +1,44 @@
import {exec} from "child_process";
import {writeFile, writeFileSync} from "fs";
function asList(hist: Map<string, number>): {contributors: { contributor: string, commits: number }[]
}{
const ls = []
hist.forEach((commits, contributor) => {
ls.push({commits, contributor})
})
ls.sort((a, b) => (b.commits - a.commits))
return {contributors: ls}
}
function main() {
exec("git log --pretty='%aN %%!%% %s' ", ((error, stdout, stderr) => {
const entries = stdout.split("\n").filter(str => str !== "")
const codeContributors = new Map<string, number>()
const translationContributors = new Map<string, number>()
for (const entry of entries) {
console.log(entry)
let [author, message] = entry.split("%!%").map(s => s.trim())
if(author === "Weblate"){
continue
}
if (author === "pietervdvn") {
author = "Pieter Vander Vennet"
}
let hist = codeContributors;
if (message.startsWith("Translated using Weblate")) {
hist = translationContributors
}
hist.set(author, 1 + (hist.get(author) ?? 0))
}
const codeContributorsTarget = "assets/contributors.json"
writeFileSync(codeContributorsTarget, JSON.stringify(asList(codeContributors)))
const translatorsTarget = "assets/translators.json"
writeFileSync(translatorsTarget, JSON.stringify(asList(translationContributors)))
}));
}
main()

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, " "))
}
@ -469,7 +487,7 @@ function mergeLayerTranslations() {
const layerFiles = ScriptUtils.getLayerFiles();
for (const layerFile of layerFiles) {
mergeLayerTranslation(layerFile.parsed, layerFile.path, loadTranslationFilesFrom("layers"))
writeFileSync(layerFile.path, JSON.stringify(layerFile.parsed, null, " "))
writeFileSync(layerFile.path, JSON.stringify(layerFile.parsed, null, " ")) // layers use 2 spaces
}
}
@ -484,7 +502,7 @@ function mergeThemeTranslations() {
const allTranslations = new TranslationPart();
allTranslations.recursiveAdd(config, themeFile.path)
writeFileSync(themeFile.path, JSON.stringify(config, null, " "))
writeFileSync(themeFile.path, JSON.stringify(config, null, " ")) // Themefiles use 2 spaces
}
}
@ -516,7 +534,12 @@ if (!themeOverwritesWeblate) {
compileTranslationsFromWeblate();
}
genTranslations()
formatFile("./langs/en.json")
const allTranslationFiles = ScriptUtils.readDirRecSync("langs").filter(path => path.endsWith(".json"))
for (const path of allTranslationFiles) {
console.log("Formatting ", path)
formatFile(path)
}
// SOme validation
TranslationPart.fromDirectory("./langs").validateStrict("./langs")