Skip to content

Commit

Permalink
assert i18n dictionaries match on app startup
Browse files Browse the repository at this point in the history
  • Loading branch information
AmrSaber committed Sep 28, 2024
1 parent 64c20b4 commit 5750c54
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/hooks.server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import '$lib/i18n/dicts/_assertions';
14 changes: 14 additions & 0 deletions src/lib/i18n/dicts/_assertions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { assert } from '$lib/utils';
import arDict from './ar';
import enDict from './en';

// Assert that languages dictionaries contain same values
{
const arKeys = new Set(Object.keys(arDict));
const enKeys = new Set(Object.keys(enDict));

const dictsUnion = arKeys.union(enKeys);
const dictsIntersection = arKeys.intersection(enKeys);
const difference = dictsUnion.difference(dictsIntersection);
assert(difference.size == 0, `i18n dictionaries have difference [${[...difference].join(', ')}]`);
}

0 comments on commit 5750c54

Please sign in to comment.