Skip to content

Instantly share code, notes, and snippets.

@chrisfls
Created July 25, 2023 20:46
Show Gist options
  • Save chrisfls/7d9a0630f028cbf0f47710bdd39f59ae to your computer and use it in GitHub Desktop.
Save chrisfls/7d9a0630f028cbf0f47710bdd39f59ae to your computer and use it in GitHub Desktop.
const translations: ({
term: string;
definition: string;
context: string;
term_plural: string;
reference: string;
comment: string;
} | {
term: string;
definition: {
one: string;
other: string;
};
context: string;
term_plural: string;
reference: string;
comment: string;
})[] = JSON.parse(Deno.readTextFileSync("WMS_Web_App_-_New_English.json"));
const changeset: Record<string, Record<string,string>> = {
}
for (const context in changeset) {
for (const term in changeset[context]) {
const index = translations.findIndex(
entry => entry.context === context && entry.term === term
);
const replacement = {
"term": term,
"definition": changeset[context][term],
"context": context,
"term_plural": "",
"reference": "",
"comment": ""
}
if (index === -1) {
translations.push(replacement);
console.log("added", context, term);
} else {
if (changeset[context][term] === translations[index].definition)
continue;
translations[index] = replacement
console.log("updated", context, term);
}
}
}
Deno.writeTextFileSync("./translations.json", JSON.stringify(translations, null, 2));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment