Make json creating scripts follow new Lean format

This commit is contained in:
Kalle
2022-09-06 20:11:33 +03:00
parent bb3552959a
commit 62aac935b2
3 changed files with 19 additions and 6 deletions

View File

@@ -10,6 +10,10 @@ import { LANG_JSONS_TO_CREATE, loadLangDicts } from "./utils";
const CURRENT_SEASON = 0;
const OUTPUT_DIR_PATH = path.join(__dirname, "output");
const LEAN_HEAD_CODE = "Hed";
const LEAN_CLOTHES_CODE = "Clt";
const LEAN_SHOES_CODE = "Shs";
async function main() {
const allGear: Array<{
id: number;
@@ -28,12 +32,20 @@ async function main() {
invariant(type);
invariant(internalName);
const categoryKey = `CommonMsg/Gear/GearName_${
type === LEAN_CLOTHES_CODE
? "Clothes"
: type === LEAN_SHOES_CODE
? "Shoes"
: "Head"
}`;
allGear.push({
id: gear.Id,
type,
internalName,
translations: langDicts.map(([langCode, translations]) => {
const name = translations[internalName];
const name = translations[categoryKey]?.[internalName];
invariant(name, `Missing translation for ${internalName}`);
return {
@@ -51,9 +63,9 @@ async function main() {
JSON.stringify(allGear, null, 2)
);
const headGear = allGear.filter((g) => g.type === "Hed");
const clothesGear = allGear.filter((g) => g.type === "Clt");
const shoesGear = allGear.filter((g) => g.type === "Shs");
const headGear = allGear.filter((g) => g.type === LEAN_HEAD_CODE);
const clothesGear = allGear.filter((g) => g.type === LEAN_CLOTHES_CODE);
const shoesGear = allGear.filter((g) => g.type === LEAN_SHOES_CODE);
invariant(headGear.length);
invariant(clothesGear.length);
invariant(shoesGear.length);

View File

@@ -6,6 +6,7 @@ import { LANG_JSONS_TO_CREATE, loadLangDicts } from "./utils";
const INTERNAL_NAMES_TO_IGNORE: readonly string[] = ["Free"] as const;
const OUTPUT_DIR_PATH = path.join(__dirname, "output");
const LEAN_WEAPON_CATEGORY_KEY = "CommonMsg/Weapon/WeaponName_Main";
async function main() {
const result: Array<{
@@ -27,7 +28,7 @@ async function main() {
id: weapon.Id,
internalName: weapon.__RowId,
translations: langDicts.map(([langCode, translations]) => {
const name = translations[weapon.__RowId];
const name = translations[LEAN_WEAPON_CATEGORY_KEY]?.[weapon.__RowId];
invariant(name);
return {

View File

@@ -18,7 +18,7 @@ export const LANG_JSONS_TO_CREATE = [
export async function loadLangDicts() {
const result: Array<
[langCode: string, translations: Record<string, string>]
[langCode: string, translations: Record<string, Record<string, string>>]
> = [];
const files = await fs.promises.readdir(LANG_DICTS_PATH);