Skip to content

Commit

Permalink
chore: next app getStaticData with namespaces (#3333)
Browse files Browse the repository at this point in the history
  • Loading branch information
stepan662 authored Apr 24, 2024
1 parent 36f8d7a commit 5286551
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions testapps/next-app/src/tolgee/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,21 @@ export const ALL_LOCALES = ['en', 'cs', 'de', 'fr'];

export const DEFAULT_LOCALE = 'en';

export async function getStaticData(languages: string[]) {
export async function getStaticData(
languages: string[],
namespaces: string[] = ['']
) {
const result: Record<string, any> = {};
for (const lang of languages) {
result[lang] = (await import(`../i18n/${lang}.json`)).default;
for (const namespace of namespaces) {
if (namespace) {
result[`${lang}:${namespace}`] = (
await import(`../i18n/${namespace}/${lang}.json`)
).default;
} else {
result[lang] = (await import(`../i18n/${lang}.json`)).default;
}
}
}
return result;
}
Expand Down

0 comments on commit 5286551

Please sign in to comment.