TASKS-1823 WebManager module

This commit is contained in:
Igor Martyniuk
2026-08-28 08:35:58 +00:00
parent fdb2cf3837
commit c93d8c025b
654 changed files with 26232 additions and 6075 deletions
+28
View File
@@ -0,0 +1,28 @@
import { hasLocale } from 'next-intl';
import { getRequestConfig } from 'next-intl/server';
import { routing } from './routing';
async function loadTranslationType(type: string, locale: string) {
try {
return (await import(`./translations/${type}/${locale}.json`)).default;
} catch {
return (await import(`./translations/${type}/${routing.defaultLocale}.json`)).default;
}
}
async function loadMessages(locale: string) {
const resources = ['messages', 'pages', 'components', 'errors', 'form'].map((type) => {
return loadTranslationType(type, locale);
});
const loaded = await Promise.all(resources);
return Object.assign({}, ...loaded);
}
export default getRequestConfig(async ({ requestLocale }) => {
const requested = await requestLocale;
const locale = hasLocale(routing.locales, requested) ? requested : routing.defaultLocale;
const messages = await loadMessages(locale);
return { locale, messages };
});