QuiiBz / next-international

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

feat(next-international): improve fallback locale API #142

Closed QuiiBz closed 1 year ago

QuiiBz commented 1 year ago

Relates to #141

Improved Fallback Locale API

⚠️ BREAKING

Improve the Fallback Locale API for both the Pages and App Router:

Pages Router

See changes for fallbackLocale prop Before: ```tsx // pages/_app.tsx import en from '../locales/en' export default function App({ Component, pageProps }: AppProps) { return ( ) } ``` After: ```tsx // pages/_app.tsx export default function App({ Component, pageProps }: AppProps) { return ( ) } ```

App Router

See changes for fallbackLocale and locale props (in Client Components) Before: ```tsx // app/[locale]/client/layout.tsx import en from '../../../locales/en' export default function SubLayout({ children, params: { locale } }: { children: ReactNode; params: { locale: string } }) { return ( {children} ) } ``` After: ```tsx // app/[locale]/client/layout.tsx import en from '../../../locales/en' export default function SubLayout({ children }: { children: ReactNode }) { return ( {children} ) } ```

This release also adds missing support for fallback locales on the server with the App Router. Navigate to locales/server.ts and add a new fallbackLocale option:

// locales/server.ts
export const {
  ...
} = createI18nServer({
  ...
}, {
  fallbackLocale: 'en'
})
vercel[bot] commented 1 year ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
next-international ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 31, 2023 5:01pm