Repository navigation
v0.167.0
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, auseQuerythe render discovers) ran its api handler in a fresh request context with no locale, soreq.locale()wasnullthere. A page at/tr-TR/...or with ani18n-locale=tr-TRcookie 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 atr-TRcookie staysen-US. req.locale()now falls back to detection (cookie, thenAccept-Language) when nothing resolved a locale, asLang.locale()already did. This also covers api routes of apps that configure onlysupportedLocales(no legacyprefetchdictionaries), where it used to returnnull. With no locales configured, it returns what it returned before (nullon an api request).