-
Is your feature request related to a problem? Please describe.I'm trying to have the same config and implementation of Describe the solution you'd likeI would like to have a package of turborepo like Describe alternatives you've consideredI've considered alterning the settings of the repo, changing the path, none of those worked. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 23 replies
-
You can customize the path to I'll move this to a discussion since it seems to be a usage question. |
Beta Was this translation helpful? Give feedback.
-
Hi everyone, I came across this discussion and wanted to better understand how In my case, I have multiple websites within the same monorepo, each with different routing configurations, but all aiming to reuse shareable parts. However, the current approach using This would allow us to create reusable modules containing navigation, making composition much easier — since routing is ultimately a responsibility of the application itself, not the shared component or package. That said, I’ve created a shared package that includes routing, request handling, navigation, and messages. I’m integrating it using: createNextIntlPlugin("../../packages/i18n/src/request.ts") But I'm getting an error during integration:
I’m still digging to see if this is a mistake on my side, but I believe it would be awesome if the navigation could dynamically inherit routing from the consuming app. That would make multi-app setups much more ergonomic. Would love to hear if anyone has experience with this or ideas on how to improve this kind of integration. |
Beta Was this translation helpful? Give feedback.
-
Working on a solution now. |
Beta Was this translation helpful? Give feedback.
-
I am doing this way. import {hasLocale} from 'next-intl';
import {getRequestConfig} from 'next-intl/server';
import {routing} from './routing';
export default getRequestConfig(async function createRequestConfig({
requestLocale,
}) {
// This typically corresponds to the `[locale]` segment
const requested = await requestLocale;
const locale = hasLocale(routing.locales, requested)
? requested
: routing.defaultLocale;
let messages;
try {
messages = (
await (locale === routing.defaultLocale
? import(`../messages/en.json`)
: import(`../messages/${locale}.json`))
).default;
} catch (error) {
console.error(`Failed to load messages for locale: ${locale}`, error);
messages = (await import(`../messages/en.json`)).default;
}
return {
locale,
messages,
};
}); in
then in my export {default} from '@ezy/i18n/request'; I am also able to share my messages type across package or app. Here how I share types import defaultLang from '../messages/en.json';
import type {Locale} from './available-languages';
type Messages = typeof defaultLang;
declare module 'next-intl' {
interface AppConfig {
Messages: Messages;
Locale: Locale;
}
} then in other package or app (in my case I used i18n type builder package and in web app)
in {
...
"compilerOptions": {
"types": ["@ezy/i18n/i18n.d.ts"],
....
},
"include": ["src", "types.d.ts", "i18n-env.d.ts"],
} Now I am getting full typed next-intl from my local i18n package. |
Beta Was this translation helpful? Give feedback.
I am doing this way.
packages/i18n/src/request.ts
: