QuiiBz / next-international

Type-safe internationalization (i18n) for Next.js
https://next-international.vercel.app
MIT License
1.2k stars 52 forks source link

Question: How to set a default lang and fallback lang in the pages dir #350

Closed FleetAdmiralJakob closed 4 months ago

FleetAdmiralJakob commented 4 months ago

Disclaimer: I think this question and others like #347 would fit better in a discussion but because I can't open a discussion in this repo I created an issue.

I'm new and come from next-i18next there you can define the default lang and fallback lang like this:

/** @type {import('next-i18next').UserConfig} */
module.exports = {
  i18n: {
    defaultLocale: "en",
    locales: ["en", "de"],
  },
  fallbackLng: {
    default: ["en"],
  },
};

In the app router for next-international there you can define the default and fallback lang but not for the pages router. (At least it is not shown in the documentation),

QuiiBz commented 4 months ago

You can configure it inside next.config.js: https://nextjs.org/docs/pages/building-your-application/routing/internationalization

Screenshot 2024-02-09 at 15 22 36
FleetAdmiralJakob commented 4 months ago

And how to set a fallback lang? This example is only for the default locale ig.

QuiiBz commented 4 months ago

You can set the fallbackLocale prop on I18nProvider: https://github.com/QuiiBz/next-international/blob/a049386f43bf2c42a2b3ed9b8d3e82b42ff9eebe/examples/next-pages/pages/_app.tsx#L8

See the documentation here.