Releases: QuiiBz/next-international
1.2.4
1.2.3
1.2.2
1.2.1
1.2.0
What's Changed
- perf(next-international): optimize middleware by @Yovach in #292
- perf(next-international): cache locales by @QuiiBz in #314
- chore: update nextjs to 14 by @QuiiBz in #315
- feat(docs): add
@vercel/speed-insights
by @QuiiBz in #318 - fix: execute function in I18nProviderWrapper instead of I18nProvider by @Yovach in #316
- feat: avoid refresh if new locale is already the current locale by @moinulmoin in #322
New Contributors
- @moinulmoin made their first contribution in #322
Full Changelog: 1.1.4...1.2.0
1.1.4
What's Changed
- chore: bump next to 13.5.6 by @QuiiBz in #260
- chore: update all deps by @QuiiBz in #264
- refactor: Update error message for clarity on defined locales by @ichiwa in #252
- feat(next-international): set samesite attribute on cookies by @kristofferso in #269
- fix(next-international): preserve cookies in the middleware by @Yovach in #271
- chore(docs): add rtl support by @gustaveWPM in #273
- chore(docs): improve RTL docs by @QuiiBz in #274
- chore: add
CONTRIBUTING.md
by @QuiiBz in #280
New Contributors
- @ichiwa made their first contribution in #252
- @kristofferso made their first contribution in #269
- @gustaveWPM made their first contribution in #273
Full Changelog: 1.1.3...1.1.4
1.1.3
What's Changed
- feat(docs): add darkmode by @Willem-Jaap in #243
- chore: bump next, next-eslint-plugin, nextra by @QuiiBz in #244
- fix(next-international): rewrite strategies keep search params by @QuiiBz in #246
New Contributors
- @Willem-Jaap made their first contribution in #243
Full Changelog: 1.1.2...1.1.3
1.1.2
What's Changed
- feat(next-international): export internal functions by @QuiiBz in #232
- fix(international-types): flatten works with dot & object notation by @QuiiBz in #236
- chore: bump next & nextra by @QuiiBz in #226
- perf(next-international): use optional
String.prototype.split
param by @Yovach in #238 - chore: enforce types imports by @Yovach in #237
- feat(next-international): only trigger suspense on first load by @QuiiBz in #234
New Contributors
Full Changelog: 1.1.0...1.1.2
1.1.0
next-international 1.1.0 includes new features and improvements for the App Router. Upgrade now by installing the latest version:
pnpm install next-international@latest
- 🎉 New features
- Plurals with
#zero
works with{ count: 0 }
(App & Pages Router) - Preserve search params (App Router)
rewriteDefault
strategy redirects to hide the default locale (App Router)
- Plurals with
⚠️ Breaking changes- Support Static Rendering in nested Client Components (App Router)
Plurals with #zero
works with { count: 0 }
(App & Pages Router)
Previously, plurals using #zero
only worked with { count: 0 }
for some languages, because of how the Intl.PluralRules
API works. We extended it to make it available on any language, so this example now works as expected:
// locales/en.ts
export default {
'cows#zero': 'No cows',
'cows#one': 'A cow',
'cows#other': '{count} cows'
} as const
t('cows', { count: 0 }) // No cows
t('cows', { count: 1 }) // A cow
t('cows', { count: 3 }) // 3 cows
Preserve search params (App Router)
By default, next-international doesn't preserve search params when changing the locale. This is because useSearchParams()
will opt-out the page from Static Rendering if you don't wrap the component in a Suspense
boundary.
If you want to preserve search params, you can manually use the preserveSearchParams
option inside useChangeLocale
:
// Client Component
'use client'
import { useChangeLocale } from '../../locales/client'
export function ChangeLocaleButton() {
const changeLocale = useChangeLocale({ preserveSearchParams: true })
...
}
Then, don't forget to wrap the component in a Suspense
boundary to avoid opting out the entire page from Static Rendering:
// Client or Server Component
import { ChangeLocaleButton } from './change-locale-button'
export default function Page() {
return (
<Suspense>
<ChangeLocaleButton />
</Suspense>
)
}
rewriteDefault
strategy redirects to hide default locale (App Router)
The rewriteDefault
strategy used to only show the locale segment in the URL when not using the default locale now redirects and hides the default locale to avoid having the same page twice.
Default locale: en
Before | After |
---|---|
/ → / |
/ → / |
/en → /en |
/en → / |
/fr → /fr |
/fr → /fr |
Support Static Rendering in nested Client Components (App Router)
We had an issue that would show the keys instead of the translation when statically rendering a page that had Client Components. The correct translation would only be set during hydration.
The fallbackLocale
prop has been moved from I18nProviderClient
to createI18nClient
, to match createI18nServer
:
See changes
Before
// app/[locale]/client/layout.tsx
'use client'
import en from '../../locales/en'
export default function Layout({ children }: { children: ReactElement }) {
return (
<I18nProviderClient fallbackLocale={en}>
{children}
</I18nProviderClient>
)
}
// locales/client.ts
import en from './en'
export const {
...
} = createI18nClient({
...
})
After:
// app/[locale]/client/layout.tsx
'use client'
export default function Layout({ children, params: { locale } }: { children: ReactElement, params: { locale: string } }) {
return (
<I18nProviderClient locale={locale}>
{children}
</I18nProviderClient>
)
}
// locales/client.ts
import en from './en'
export const {
...
} = createI18nClient({
...
}, {
fallbackLocale: en
})
What's Changed
- chore: update sponsors by @QuiiBz in #176
- chore: update sponsors url by @QuiiBz in #177
- chore: add sherif to lint monorepo by @QuiiBz in #185
- ci: update sherif by @QuiiBz in #203
- chore(docs): add
'use client'
annotation by @medyahyejoud in #215 - ci: fix sherif by @QuiiBz in #218
- feat: 1.1.0 by @QuiiBz in #205
New Contributors
- @medyahyejoud made their first contribution in #215
Full Changelog: 1.0.1...1.1.0
1.0.1
What's Changed
- fix(next-international): flatten locale in
getLocaleProps
by @lindesvard in #166 - chore(docs): add bun installation support by @poypoydev in #167
- fix(next-international): remove unintended log in middleware by @zackrw in #168
- chore: update sponsors by @QuiiBz in #169
- fix(next-international): fallbackLocale with dot-notation TS error by @QuiiBz in #174
- fix(next-international): respect rewriteDefault strategy when changing locale by @QuiiBz in #175
New Contributors
- @lindesvard made their first contribution in #166
- @poypoydev made their first contribution in #167
Full Changelog: 1.0.0...1.0.1