This moves around translations (i.e. giving them a different key), mostly to transition to the nested form. This PR also removes unused translations. Not all keys are in the nested form yet as I lost motivation at this point some are just used in several places and don't fit well into the nested structure. Finally, Greek and Turkish are removed. See the relevant commit for more info.
This is quite a big and annoying-to-review PR, unfortunately. I don't think a code review is useful or necessary:
Thanks to Typescript, every translation key used in code is checked against en.json. Thus, all used translation keys at least exist in the English file!
Locally, with a few quick'n'dirty scripts, I made sure that all other JSON files only contain a subset of the keys of the English file. (See scripts below)
I am very sure that I didn't accidentally remove translations while moving them around.
To check whether a translation is unused, it is not sufficient to just grep its key. In code, we sometimes use something like t(`foo-${yes ? "cat" : "dog"}`). Which Typescript is able to understand, but grep doesn't of course. So for those false positives "unused" translations I checked again manually. And again: I can't accidentally remove one that is still used, as Typescript will complain.
I already asked and will still ask a few contacts to provide full translations for French, Farsi, Spanish, Chinese simplified. Those will be added in a follow up PR.
My used scripts, just for reference:
`flatten.ts`: prints the flat translation keys of a JSON file. Run with `deno --allow-read flatten.ts -- path/to/file`.
```
const flatten = (obj: object, prefix: string) => {
for (const key in obj) {
if (isObject(obj[key])) {
flatten(obj[key], `${prefix}${key}.`);
} else {
console.log(`${prefix}${key}`);
}
}
};
const isObject = (v: unknown): v is object => (
typeof v === "object" && !Array.isArray(v) && v !== null
);
const filename = Deno.args[1];
const content = await Deno.readTextFile(filename);
const jsonIn = JSON.parse(content);
flatten(jsonIn, "");
```
Run that for `en.json` and save to `enkeys.txt`. Then run this script on the output of `flatten.ts` for all other files:
```
#!/bin/bash
while IFS= read -r line
do
rg -q "$line" ./enkeys.txt || echo "$line"
done
```
Fixes #1075
This moves around translations (i.e. giving them a different key), mostly to transition to the nested form. This PR also removes unused translations. Not all keys are in the nested form yet as
I lost motivation at this pointsome are just used in several places and don't fit well into the nested structure. Finally, Greek and Turkish are removed. See the relevant commit for more info.This is quite a big and annoying-to-review PR, unfortunately. I don't think a code review is useful or necessary:
en.json
. Thus, all used translation keys at least exist in the English file!t(`foo-${yes ? "cat" : "dog"}`)
. Which Typescript is able to understand, but grep doesn't of course. So for those false positives "unused" translations I checked again manually. And again: I can't accidentally remove one that is still used, as Typescript will complain.I already asked and will still ask a few contacts to provide full translations for French, Farsi, Spanish, Chinese simplified. Those will be added in a follow up PR.
My used scripts, just for reference: