-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathdictionaries.ts
More file actions
17 lines (15 loc) · 850 Bytes
/
dictionaries.ts
File metadata and controls
17 lines (15 loc) · 850 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import { Dictionary } from '@/types/dictionary'; // Adjust path as necessary
// Typing the dictionaries object to ensure each key returns a Promise<Dictionary>
const dictionaries: Record<string, () => Promise<Dictionary>> = {
en: () => import('./dictionaries/en.json').then((module) => module.default),
ca: () => import('./dictionaries/ca.json').then((module) => module.default),
es: () => import('./dictionaries/es.json').then((module) => module.default),
fr: () => import('./dictionaries/fr.json').then((module) => module.default),
};
// Explicitly typing getDictionary to return a Promise<Dictionary>
export const getDictionary = async (locale: string): Promise<Dictionary> => {
if (!dictionaries[locale]) {
throw new Error(`Dictionary for locale "${locale}" not found.`);
}
return dictionaries[locale]();
};