Replies: 1 comment 4 replies
-
This is how I have mine configured and it works: // src/i18n.ts
import { notFound } from 'next/navigation';
import { getRequestConfig } from 'next-intl/server';
// Can be imported from a shared config
const locales = ['en', 'ro'];
export default getRequestConfig(async ({ locale }) => {
// Validate that the incoming `locale` parameter is valid
if (!locales.includes(locale as any)) notFound();
// Updated path to reflect the new location at src/messages
return {
messages: (await import(`./messages/${locale}.json`)).default
};
}); I hope it helps. |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have a trouble with write code. In your project (examples/example-app-router/src/i18n.ts) in return you wrote like
import('../messages/${locale}.json')
. I don't know why, but next says no such module is found.Although I have the correct folder and file structure. However, if I write
import('../messages/en.json')
orimport('../messages/de.json')
(desired language) then everything is fine.Having said that, I have 4 languages and I can't give the exact path either, writing 4 imports it seems wrong
Beta Was this translation helpful? Give feedback.
All reactions