diff --git a/src/renderer/src/lib/GameState.ts b/src/renderer/src/lib/GameState.ts index af4097e..7db44e0 100644 --- a/src/renderer/src/lib/GameState.ts +++ b/src/renderer/src/lib/GameState.ts @@ -25,7 +25,7 @@ export interface LocalizedText { key: string; variables?: { key: string; - value: LocalizedText; + value?: LocalizedText; }[]; } const localizedTextSchemaNoDefault: z.ZodType = z.object({ @@ -34,7 +34,7 @@ const localizedTextSchemaNoDefault: z.ZodType = z.object({ .array( z.object({ key: z.coerce.string(), - value: z.lazy(() => localizedTextSchemaNoDefault), + value: z.lazy(() => localizedTextSchemaNoDefault.optional()), }), ) .optional(), diff --git a/src/renderer/src/lib/map/data/locUtils.ts b/src/renderer/src/lib/map/data/locUtils.ts index b841936..a004421 100644 --- a/src/renderer/src/lib/map/data/locUtils.ts +++ b/src/renderer/src/lib/map/data/locUtils.ts @@ -26,7 +26,7 @@ export function localizeTextSync( } else if (text.key === '%ADJ%') { try { const var0 = text.variables?.[0]; - if (!var0 || !var0.value.variables) throw new Error(); + if (!var0 || !var0.value?.variables) throw new Error(); const adj = loc[var0.value.key] ?? var0.value.key; if (adj.includes('$1$')) { return localizeTextSync(var0.value, loc);