Setup Translations
Setup i18n (Locale) in your project
- Follow the official step-by-step guide : https://next-intl.dev/docs/getting-started/app-router/with-i18n-routing
In src/i18n/request.ts
- Create an object messages, add the local app messages translation files and add the translation file from the bundle to translate the components coming from bundle and then return messages
const messages = {
...((await import(`../../messages/${locale}.json`)).default || {}),
};
const componentsBundleMessages = (
// Adapt to the path to your node_modules
await import(
`../../node_modules/@phpcreation/frontend-components-react-nextjs-bundle/messages/${locale}.json`
)
).default;
Object.assign(messages, componentsBundleMessages);How to use it ?
- When you want to add a translation specific to your app, add it in the local app messages folder
- When it’s a translation that is used in multiple apps, add it in the components bundle messages folder add
Last updated on