import { describe, expect, it } from 'vitest' import en from '../i18n/locales/en.json' import sk from '../i18n/locales/sk.json' type JsonValue = string | number | boolean | null | JsonObject | JsonValue[] type JsonObject = Record function collectLeafPaths(value: JsonValue, prefix = ''): string[] { if (Array.isArray(value)) { return value.flatMap((item, index) => collectLeafPaths(item, `${prefix}[${index}]`)) } if (value !== null && typeof value === 'object') { return Object.entries(value as JsonObject).flatMap(([key, nestedValue]) => collectLeafPaths(nestedValue, prefix ? `${prefix}.${key}` : key) ) } return [prefix] } describe('i18n locale files', () => { it('keep the same translation key structure in slovak and english', () => { const skPaths = collectLeafPaths(sk as JsonObject).sort() const enPaths = collectLeafPaths(en as JsonObject).sort() expect(skPaths).toEqual(enPaths) }) })