Next.js Discord

Discord Forum

How to handle locale in getTranslations if I'm Not Using Multiple Locales in url?

Answered
Southeastern blueberry bee posted this in #help-forum
Open in Discord
Southeastern blueberry beeOP
I'm using this function to generate localized metadata in layout.tsx, I don't use multiple locales (/en/..) in my app:

export async function generateMetadata({
  params: { locale },
}: {
  params: { locale: string };
}) {
  const t = await getTranslations({ locale: locale, namespace: "Navbar" });
  return {
    title: t("profile"),
    description: t("profile"),
  };
}


Should I remove the locale parameter or set as undefined,
or is there a better way to handle it?
Answered by Asian black bear
If this is next-intl just use getTranslations('Navbar').
View full answer

2 Replies

Asian black bear
If this is next-intl just use getTranslations('Navbar').
Answer
Southeastern blueberry beeOP
That helped, thanks