wacrm/src/i18n/request.ts

20 lines
543 B
TypeScript

import { getRequestConfig } from 'next-intl/server';
export default getRequestConfig(async () => {
// Read the locale from the environment, defaulting to 'en'
const locale = process.env.NEXT_PUBLIC_APP_LOCALE || 'en';
let messages;
try {
messages = (await import(`../../messages/${locale}.json`)).default;
} catch (error) {
// Fallback to English if the dictionary for the requested locale doesn't exist yet
messages = (await import(`../../messages/en.json`)).default;
}
return {
locale,
messages
};
});