Skip to content

v0.167.0

Choose a tag to compare

@nstfkc nstfkc released this 29 Oct 08:00
· 29 commits to main since this release

i18n: server-side queries run in the page's locale (#1074)

Fix (minor: req.locale() on api routes can now return a detected locale where it returned null). Check code that treats null as "no locale chosen".

  • A query run during SSR (Query.prefetch, Query.instant, a useQuery the render discovers) ran its api handler in a fresh request context with no locale, so req.locale() was null there. A page at /tr-TR/... or with an i18n-locale=tr-TR cookie shipped SSR data in the default locale, which flipped to the right one on the first client refetch.
  • The query's context now takes the locale the page resolved: the URL prefix first, then the cookie, then Accept-Language. /en-US/... with a tr-TR cookie stays en-US.
  • req.locale() now falls back to detection (cookie, then Accept-Language) when nothing resolved a locale, as Lang.locale() already did. This also covers api routes of apps that configure only supportedLocales (no legacy prefetch dictionaries), where it used to return null. With no locales configured, it returns what it returned before (null on an api request).