mirror of
https://github.com/Luchexx/wacrm.git
synced 2026-11-02 09:19:51 +00:00
feat: add fallback logic for missing locale dictionaries and update NextIntlClientProvider configuration
This commit is contained in:
parent
1ce9581117
commit
50d71b1ed6
@ -42,7 +42,7 @@ META_APP_SECRET=your-meta-app-secret
|
||||
# or a background worker that has no incoming request.
|
||||
NEXT_PUBLIC_SITE_URL=https://crm.example.com
|
||||
|
||||
# Default language locale (e.g. en, es)
|
||||
# Default language locale (e.g. en)
|
||||
NEXT_PUBLIC_APP_LOCALE=en
|
||||
|
||||
# ============================================================
|
||||
|
||||
@ -108,7 +108,7 @@ export default async function RootLayout({
|
||||
/>
|
||||
</head>
|
||||
<body className="min-h-full bg-background text-foreground font-sans">
|
||||
<NextIntlClientProvider messages={messages}>
|
||||
<NextIntlClientProvider messages={messages} locale={locale}>
|
||||
<ThemeProvider>
|
||||
{children}
|
||||
<ThemedToaster />
|
||||
|
||||
@ -4,8 +4,16 @@ 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: (await import(`../../messages/${locale}.json`)).default
|
||||
messages
|
||||
};
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user