From 1c18ffdc8e2d4b362bbcde8f8fc61976efa23823 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BAlio=20M=C3=BChlbauer?= <53458125+juliomuhlbauer@users.noreply.github.com> Date: Thu, 25 Dec 2025 14:42:28 -0300 Subject: [PATCH 01/13] (docs): add i18n guide --- .../react/guide/internationalization-i18n.md | 296 ++++++++++++++++++ 1 file changed, 296 insertions(+) create mode 100644 docs/router/framework/react/guide/internationalization-i18n.md diff --git a/docs/router/framework/react/guide/internationalization-i18n.md b/docs/router/framework/react/guide/internationalization-i18n.md new file mode 100644 index 0000000000..a3a0314a23 --- /dev/null +++ b/docs/router/framework/react/guide/internationalization-i18n.md @@ -0,0 +1,296 @@ +--- +title: Internationalization (i18n) +--- + +TanStack Router provides flexible and highly customizable primitives that can be composed to support common internationalization (i18n) routing patterns, such as **optional path parameters**, **route rewriting**, and **type-safe params**. This enables clean, SEO-friendly URLs, flexible locale handling, and seamless integration with i18n libraries. + +This guide covers: + +* Prefix-based and optional-locale routing +* Advanced routing patterns for i18n +* Language navigation and switching +* SEO considerations +* Type safety +* Integration patterns with i18n libraries (Paraglide) + +--- + +## i18n with Optional Path Parameters + +This pattern relies exclusively on TanStack Router features. It is suitable when: + +* You want full control over translations +* You already manage translations manually +* You do not need automatic locale detection + +Optional path parameters are ideal for implementing locale-aware routing without duplicating routes. + +```ts +/{-$locale}/about +``` + +This single route matches: + +* `/about` (default locale) +* `/en/about` +* `/fr/about` +* `/es/about` + +### Prefix-based i18n + +```tsx +// Route: /{-$locale}/about +export const Route = createFileRoute('/{-$locale}/about')({ + component: AboutComponent, +}) + +function AboutComponent() { + const { locale } = Route.useParams() + const currentLocale = locale || 'en' + + const content = { + en: { title: 'About Us' }, + fr: { title: 'À Propos' }, + es: { title: 'Acerca de' }, + } + + return

{content[currentLocale].title}

+} +``` + +### Complex Routing Patterns + +```tsx +// Route: /{-$locale}/blog/{-$category}/$slug +export const Route = createFileRoute('/{-$locale}/blog/{-$category}/$slug')({ + beforeLoad: ({ params }) => { + const locale = params.locale || 'en' + const validLocales = ['en', 'fr', 'es', 'de'] + + if (params.locale && !validLocales.includes(params.locale)) { + throw new Error('Invalid locale') + } + + return { locale } + }, +}) +``` + +### Language Switching + +```tsx + ({ + ...prev, + locale: prev.locale === 'en' ? undefined : 'fr', + })} +> + Français + +``` + +### Type-safe Locales + +```ts +type Locale = 'en' | 'fr' | 'es' | 'de' + +function isLocale(value?: string): value is Locale { + return ['en', 'fr', 'es', 'de'].includes(value as Locale) +} +``` + +--- + +--- + +## i18n Library Integration Patterns + +TanStack Router is **library-agnostic**. You can integrate any i18n solution by mapping locale state to routing behavior. + +Below is a recommended pattern using **Paraglide**. + +--- + +## Client-side i18n with a Library (TanStack Router) + +This pattern combines TanStack Router with a client-side i18n library. It is suitable when: + +* You want type-safe translations +* You want localized URLs +* You do not need server-side rendering + +### TanStack Router + Paraglide (Client-only) + +Paraglide provides type-safe translations, locale detection, and URL localization that pair naturally with TanStack Router. + +**GitHub example:** +[https://github.com/TanStack/router/tree/main/examples/react/i18n-paraglide](https://github.com/TanStack/router/tree/main/examples/react/i18n-paraglide) + +### Project Setup + +```bash +npx @inlang/paraglide-js@latest init +``` + +```ts +import { paraglideVitePlugin } from '@inlang/paraglide-js' + +paraglideVitePlugin({ + project: './project.inlang', + outdir: './app/paraglide', +}) +``` + +### URL Localization via Router Rewrite + +```ts +import { deLocalizeUrl, localizeUrl } from './paraglide/runtime' + +const router = createRouter({ + routeTree, + rewrite: { + input: ({ url }) => deLocalizeUrl(url), + output: ({ url }) => localizeUrl(url), + }, +}) +``` + +--- + +--- + +--- + +## Server-side i18n (TanStack Start) + +This pattern integrates i18n at the routing and server layers. It is suitable when: + +* You use TanStack Start +* You need SSR or streaming +* You want locale-aware redirects and metadata + +### TanStack Start + Paraglide + +**GitHub example:** +[https://github.com/TanStack/router/tree/main/examples/react/start-i18n-paraglide](https://github.com/TanStack/router/tree/main/examples/react/start-i18n-paraglide) + +### Server Middleware (SSR) + +````ts +import { paraglideMiddleware } from './paraglide/server' + +export default { + fetch(req: Request) { + return paraglideMiddleware(req, ({ request }) => + handler.fetch(request), + ) + }, +} +```ts +import { paraglideMiddleware } from './paraglide/server' + +export default { + fetch(req: Request) { + return paraglideMiddleware(req, ({ request }) => + handler.fetch(request), + ) + }, +} +```` + +Set the `` attribute from Paraglide: + +```tsx +import { getLocale } from '../paraglide/runtime' + + +``` + +Set the `` attribute from Paraglide: + +```tsx +import { getLocale } from '../paraglide/runtime' + + +``` + +--- + +## Offline-safe Redirects + +For offline or client-only environments: + +```ts +import { shouldRedirect } from '../paraglide/runtime' + +beforeLoad: async () => { + const decision = await shouldRedirect({ url: window.location.href }) + if (decision.redirectUrl) { + throw redirect({ href: decision.redirectUrl.href }) + } +} +``` + +--- + +## Type-safe Translated Pathnames + +To ensure every route has translations, you can derive translated pathnames directly from the TanStack Router route tree. + +```ts +import { FileRoutesByTo } from '../routeTree.gen' +import { Locale } from '@/paraglide/runtime' +``` + +This guarantees: + +* No missing translations +* Full type safety +* Compiler feedback for routing mistakes + +--- + +### HTML Language Attribute + +```tsx +import { getLocale } from '../paraglide/runtime' + + +``` + +### Offline-safe Redirects + +```ts +import { shouldRedirect } from '../paraglide/runtime' + +beforeLoad: async () => { + const decision = await shouldRedirect({ url: window.location.href }) + if (decision.redirectUrl) { + throw redirect({ href: decision.redirectUrl.href }) + } +} +``` + +### Prerendering Localized Routes + +```ts +import { localizeHref } from './paraglide/runtime' + +export const prerenderRoutes = ['/', '/about'].map((path) => ({ + path: localizeHref(path), + prerender: { enabled: true }, +})) +``` + +## Additional i18n Integration Patterns + +### Intlayer (TanStack Start integration) + +[https://intlayer.org/doc/environment/tanstack-start](https://intlayer.org/doc/environment/tanstack-start) + +### use-intl (TanStack Start integration) + +[https://nikuscs.com/blog/13-tanstackstart-i18n/](https://nikuscs.com/blog/13-tanstackstart-i18n/)** + +* **TanStack Start i18n (blog)** — [https://nikuscs.com/blog/13-tanstackstart-i18n/](https://nikuscs.com/blog/13-tanstackstart-i18n/)## Additional i18n Integration Patterns \ No newline at end of file From 5ca14569235e0651d17051fc9b7221a4258d743d Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Thu, 25 Dec 2025 17:44:22 +0000 Subject: [PATCH 02/13] ci: apply automated fixes --- .../react/guide/internationalization-i18n.md | 592 +++++++++--------- 1 file changed, 296 insertions(+), 296 deletions(-) diff --git a/docs/router/framework/react/guide/internationalization-i18n.md b/docs/router/framework/react/guide/internationalization-i18n.md index a3a0314a23..ac33a3b802 100644 --- a/docs/router/framework/react/guide/internationalization-i18n.md +++ b/docs/router/framework/react/guide/internationalization-i18n.md @@ -1,296 +1,296 @@ ---- -title: Internationalization (i18n) ---- - -TanStack Router provides flexible and highly customizable primitives that can be composed to support common internationalization (i18n) routing patterns, such as **optional path parameters**, **route rewriting**, and **type-safe params**. This enables clean, SEO-friendly URLs, flexible locale handling, and seamless integration with i18n libraries. - -This guide covers: - -* Prefix-based and optional-locale routing -* Advanced routing patterns for i18n -* Language navigation and switching -* SEO considerations -* Type safety -* Integration patterns with i18n libraries (Paraglide) - ---- - -## i18n with Optional Path Parameters - -This pattern relies exclusively on TanStack Router features. It is suitable when: - -* You want full control over translations -* You already manage translations manually -* You do not need automatic locale detection - -Optional path parameters are ideal for implementing locale-aware routing without duplicating routes. - -```ts -/{-$locale}/about -``` - -This single route matches: - -* `/about` (default locale) -* `/en/about` -* `/fr/about` -* `/es/about` - -### Prefix-based i18n - -```tsx -// Route: /{-$locale}/about -export const Route = createFileRoute('/{-$locale}/about')({ - component: AboutComponent, -}) - -function AboutComponent() { - const { locale } = Route.useParams() - const currentLocale = locale || 'en' - - const content = { - en: { title: 'About Us' }, - fr: { title: 'À Propos' }, - es: { title: 'Acerca de' }, - } - - return

{content[currentLocale].title}

-} -``` - -### Complex Routing Patterns - -```tsx -// Route: /{-$locale}/blog/{-$category}/$slug -export const Route = createFileRoute('/{-$locale}/blog/{-$category}/$slug')({ - beforeLoad: ({ params }) => { - const locale = params.locale || 'en' - const validLocales = ['en', 'fr', 'es', 'de'] - - if (params.locale && !validLocales.includes(params.locale)) { - throw new Error('Invalid locale') - } - - return { locale } - }, -}) -``` - -### Language Switching - -```tsx - ({ - ...prev, - locale: prev.locale === 'en' ? undefined : 'fr', - })} -> - Français - -``` - -### Type-safe Locales - -```ts -type Locale = 'en' | 'fr' | 'es' | 'de' - -function isLocale(value?: string): value is Locale { - return ['en', 'fr', 'es', 'de'].includes(value as Locale) -} -``` - ---- - ---- - -## i18n Library Integration Patterns - -TanStack Router is **library-agnostic**. You can integrate any i18n solution by mapping locale state to routing behavior. - -Below is a recommended pattern using **Paraglide**. - ---- - -## Client-side i18n with a Library (TanStack Router) - -This pattern combines TanStack Router with a client-side i18n library. It is suitable when: - -* You want type-safe translations -* You want localized URLs -* You do not need server-side rendering - -### TanStack Router + Paraglide (Client-only) - -Paraglide provides type-safe translations, locale detection, and URL localization that pair naturally with TanStack Router. - -**GitHub example:** -[https://github.com/TanStack/router/tree/main/examples/react/i18n-paraglide](https://github.com/TanStack/router/tree/main/examples/react/i18n-paraglide) - -### Project Setup - -```bash -npx @inlang/paraglide-js@latest init -``` - -```ts -import { paraglideVitePlugin } from '@inlang/paraglide-js' - -paraglideVitePlugin({ - project: './project.inlang', - outdir: './app/paraglide', -}) -``` - -### URL Localization via Router Rewrite - -```ts -import { deLocalizeUrl, localizeUrl } from './paraglide/runtime' - -const router = createRouter({ - routeTree, - rewrite: { - input: ({ url }) => deLocalizeUrl(url), - output: ({ url }) => localizeUrl(url), - }, -}) -``` - ---- - ---- - ---- - -## Server-side i18n (TanStack Start) - -This pattern integrates i18n at the routing and server layers. It is suitable when: - -* You use TanStack Start -* You need SSR or streaming -* You want locale-aware redirects and metadata - -### TanStack Start + Paraglide - -**GitHub example:** -[https://github.com/TanStack/router/tree/main/examples/react/start-i18n-paraglide](https://github.com/TanStack/router/tree/main/examples/react/start-i18n-paraglide) - -### Server Middleware (SSR) - -````ts -import { paraglideMiddleware } from './paraglide/server' - -export default { - fetch(req: Request) { - return paraglideMiddleware(req, ({ request }) => - handler.fetch(request), - ) - }, -} -```ts -import { paraglideMiddleware } from './paraglide/server' - -export default { - fetch(req: Request) { - return paraglideMiddleware(req, ({ request }) => - handler.fetch(request), - ) - }, -} -```` - -Set the `` attribute from Paraglide: - -```tsx -import { getLocale } from '../paraglide/runtime' - - -``` - -Set the `` attribute from Paraglide: - -```tsx -import { getLocale } from '../paraglide/runtime' - - -``` - ---- - -## Offline-safe Redirects - -For offline or client-only environments: - -```ts -import { shouldRedirect } from '../paraglide/runtime' - -beforeLoad: async () => { - const decision = await shouldRedirect({ url: window.location.href }) - if (decision.redirectUrl) { - throw redirect({ href: decision.redirectUrl.href }) - } -} -``` - ---- - -## Type-safe Translated Pathnames - -To ensure every route has translations, you can derive translated pathnames directly from the TanStack Router route tree. - -```ts -import { FileRoutesByTo } from '../routeTree.gen' -import { Locale } from '@/paraglide/runtime' -``` - -This guarantees: - -* No missing translations -* Full type safety -* Compiler feedback for routing mistakes - ---- - -### HTML Language Attribute - -```tsx -import { getLocale } from '../paraglide/runtime' - - -``` - -### Offline-safe Redirects - -```ts -import { shouldRedirect } from '../paraglide/runtime' - -beforeLoad: async () => { - const decision = await shouldRedirect({ url: window.location.href }) - if (decision.redirectUrl) { - throw redirect({ href: decision.redirectUrl.href }) - } -} -``` - -### Prerendering Localized Routes - -```ts -import { localizeHref } from './paraglide/runtime' - -export const prerenderRoutes = ['/', '/about'].map((path) => ({ - path: localizeHref(path), - prerender: { enabled: true }, -})) -``` - -## Additional i18n Integration Patterns - -### Intlayer (TanStack Start integration) - -[https://intlayer.org/doc/environment/tanstack-start](https://intlayer.org/doc/environment/tanstack-start) - -### use-intl (TanStack Start integration) - -[https://nikuscs.com/blog/13-tanstackstart-i18n/](https://nikuscs.com/blog/13-tanstackstart-i18n/)** - -* **TanStack Start i18n (blog)** — [https://nikuscs.com/blog/13-tanstackstart-i18n/](https://nikuscs.com/blog/13-tanstackstart-i18n/)## Additional i18n Integration Patterns \ No newline at end of file +--- +title: Internationalization (i18n) +--- + +TanStack Router provides flexible and highly customizable primitives that can be composed to support common internationalization (i18n) routing patterns, such as **optional path parameters**, **route rewriting**, and **type-safe params**. This enables clean, SEO-friendly URLs, flexible locale handling, and seamless integration with i18n libraries. + +This guide covers: + +- Prefix-based and optional-locale routing +- Advanced routing patterns for i18n +- Language navigation and switching +- SEO considerations +- Type safety +- Integration patterns with i18n libraries (Paraglide) + +--- + +## i18n with Optional Path Parameters + +This pattern relies exclusively on TanStack Router features. It is suitable when: + +- You want full control over translations +- You already manage translations manually +- You do not need automatic locale detection + +Optional path parameters are ideal for implementing locale-aware routing without duplicating routes. + +```ts +;/{-$locale}/abotu +``` + +This single route matches: + +- `/about` (default locale) +- `/en/about` +- `/fr/about` +- `/es/about` + +### Prefix-based i18n + +```tsx +// Route: /{-$locale}/about +export const Route = createFileRoute('/{-$locale}/about')({ + component: AboutComponent, +}) + +function AboutComponent() { + const { locale } = Route.useParams() + const currentLocale = locale || 'en' + + const content = { + en: { title: 'About Us' }, + fr: { title: 'À Propos' }, + es: { title: 'Acerca de' }, + } + + return

{content[currentLocale].title}

+} +``` + +### Complex Routing Patterns + +```tsx +// Route: /{-$locale}/blog/{-$category}/$slug +export const Route = createFileRoute('/{-$locale}/blog/{-$category}/$slug')({ + beforeLoad: ({ params }) => { + const locale = params.locale || 'en' + const validLocales = ['en', 'fr', 'es', 'de'] + + if (params.locale && !validLocales.includes(params.locale)) { + throw new Error('Invalid locale') + } + + return { locale } + }, +}) +``` + +### Language Switching + +```tsx + ({ + ...prev, + locale: prev.locale === 'en' ? undefined : 'fr', + })} +> + Français + +``` + +### Type-safe Locales + +```ts +type Locale = 'en' | 'fr' | 'es' | 'de' + +function isLocale(value?: string): value is Locale { + return ['en', 'fr', 'es', 'de'].includes(value as Locale) +} +``` + +--- + +--- + +## i18n Library Integration Patterns + +TanStack Router is **library-agnostic**. You can integrate any i18n solution by mapping locale state to routing behavior. + +Below is a recommended pattern using **Paraglide**. + +--- + +## Client-side i18n with a Library (TanStack Router) + +This pattern combines TanStack Router with a client-side i18n library. It is suitable when: + +- You want type-safe translations +- You want localized URLs +- You do not need server-side rendering + +### TanStack Router + Paraglide (Client-only) + +Paraglide provides type-safe translations, locale detection, and URL localization that pair naturally with TanStack Router. + +**GitHub example:** +[https://github.com/TanStack/router/tree/main/examples/react/i18n-paraglide](https://github.com/TanStack/router/tree/main/examples/react/i18n-paraglide) + +### Project Setup + +```bash +npx @inlang/paraglide-js@latest init +``` + +```ts +import { paraglideVitePlugin } from '@inlang/paraglide-js' + +paraglideVitePlugin({ + project: './project.inlang', + outdir: './app/paraglide', +}) +``` + +### URL Localization via Router Rewrite + +```ts +import { deLocalizeUrl, localizeUrl } from './paraglide/runtime' + +const router = createRouter({ + routeTree, + rewrite: { + input: ({ url }) => deLocalizeUrl(url), + output: ({ url }) => localizeUrl(url), + }, +}) +``` + +--- + +--- + +--- + +## Server-side i18n (TanStack Start) + +This pattern integrates i18n at the routing and server layers. It is suitable when: + +- You use TanStack Start +- You need SSR or streaming +- You want locale-aware redirects and metadata + +### TanStack Start + Paraglide + +**GitHub example:** +[https://github.com/TanStack/router/tree/main/examples/react/start-i18n-paraglide](https://github.com/TanStack/router/tree/main/examples/react/start-i18n-paraglide) + +### Server Middleware (SSR) + +````ts +import { paraglideMiddleware } from './paraglide/server' + +export default { + fetch(req: Request) { + return paraglideMiddleware(req, ({ request }) => + handler.fetch(request), + ) + }, +} +```ts +import { paraglideMiddleware } from './paraglide/server' + +export default { + fetch(req: Request) { + return paraglideMiddleware(req, ({ request }) => + handler.fetch(request), + ) + }, +} +```` + +Set the `` attribute from Paraglide: + +```tsx +import { getLocale } from '../paraglide/runtime' + +; +``` + +Set the `` attribute from Paraglide: + +```tsx +import { getLocale } from '../paraglide/runtime' + +; +``` + +--- + +## Offline-safe Redirects + +For offline or client-only environments: + +```ts +import { shouldRedirect } from '../paraglide/runtime' + +beforeLoad: async () => { + const decision = await shouldRedirect({ url: window.location.href }) + if (decision.redirectUrl) { + throw redirect({ href: decision.redirectUrl.href }) + } +} +``` + +--- + +## Type-safe Translated Pathnames + +To ensure every route has translations, you can derive translated pathnames directly from the TanStack Router route tree. + +```ts +import { FileRoutesByTo } from '../routeTree.gen' +import { Locale } from '@/paraglide/runtime' +``` + +This guarantees: + +- No missing translations +- Full type safety +- Compiler feedback for routing mistakes + +--- + +### HTML Language Attribute + +```tsx +import { getLocale } from '../paraglide/runtime' + +; +``` + +### Offline-safe Redirects + +```ts +import { shouldRedirect } from '../paraglide/runtime' + +beforeLoad: async () => { + const decision = await shouldRedirect({ url: window.location.href }) + if (decision.redirectUrl) { + throw redirect({ href: decision.redirectUrl.href }) + } +} +``` + +### Prerendering Localized Routes + +```ts +import { localizeHref } from './paraglide/runtime' + +export const prerenderRoutes = ['/', '/about'].map((path) => ({ + path: localizeHref(path), + prerender: { enabled: true }, +})) +``` + +## Additional i18n Integration Patterns + +### Intlayer (TanStack Start integration) + +[https://intlayer.org/doc/environment/tanstack-start](https://intlayer.org/doc/environment/tanstack-start) + +### use-intl (TanStack Start integration) + +[https://nikuscs.com/blog/13-tanstackstart-i18n/](https://nikuscs.com/blog/13-tanstackstart-i18n/)\*\* + +- **TanStack Start i18n (blog)** — [https://nikuscs.com/blog/13-tanstackstart-i18n/](https://nikuscs.com/blog/13-tanstackstart-i18n/)## Additional i18n Integration Patterns From 62c7d26923f03a6a0bb7b70a8652a4a6f14abf90 Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Thu, 25 Dec 2025 17:45:32 +0000 Subject: [PATCH 03/13] ci: apply automated fixes (attempt 2/3) --- docs/router/framework/react/guide/internationalization-i18n.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/docs/router/framework/react/guide/internationalization-i18n.md b/docs/router/framework/react/guide/internationalization-i18n.md index ac33a3b802..82cac466ac 100644 --- a/docs/router/framework/react/guide/internationalization-i18n.md +++ b/docs/router/framework/react/guide/internationalization-i18n.md @@ -203,7 +203,6 @@ Set the `` attribute from Paraglide: ```tsx import { getLocale } from '../paraglide/runtime' - ; ``` @@ -211,7 +210,6 @@ Set the `` attribute from Paraglide: ```tsx import { getLocale } from '../paraglide/runtime' - ; ``` @@ -255,7 +253,6 @@ This guarantees: ```tsx import { getLocale } from '../paraglide/runtime' - ; ``` From d9aac97f56c3521c7644694b5dc8502f164c27d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BAlio=20M=C3=BChlbauer?= <53458125+juliomuhlbauer@users.noreply.github.com> Date: Thu, 25 Dec 2025 14:51:06 -0300 Subject: [PATCH 04/13] clean --- .../react/guide/internationalization-i18n.md | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/docs/router/framework/react/guide/internationalization-i18n.md b/docs/router/framework/react/guide/internationalization-i18n.md index 82cac466ac..cebf8f30a8 100644 --- a/docs/router/framework/react/guide/internationalization-i18n.md +++ b/docs/router/framework/react/guide/internationalization-i18n.md @@ -158,10 +158,6 @@ const router = createRouter({ --- ---- - ---- - ## Server-side i18n (TanStack Start) This pattern integrates i18n at the routing and server layers. It is suitable when: @@ -187,6 +183,7 @@ export default { ) }, } + ```ts import { paraglideMiddleware } from './paraglide/server' @@ -197,22 +194,17 @@ export default { ) }, } -```` - -Set the `` attribute from Paraglide: - -```tsx -import { getLocale } from '../paraglide/runtime' -; ``` Set the `` attribute from Paraglide: ```tsx import { getLocale } from '../paraglide/runtime' -; + + ``` + --- ## Offline-safe Redirects @@ -253,7 +245,8 @@ This guarantees: ```tsx import { getLocale } from '../paraglide/runtime' -; + + ``` ### Offline-safe Redirects From b0bbd5fab95e2c8e1f194fdd36462cc94d807595 Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Thu, 25 Dec 2025 17:52:05 +0000 Subject: [PATCH 05/13] ci: apply automated fixes --- docs/router/framework/react/guide/internationalization-i18n.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/router/framework/react/guide/internationalization-i18n.md b/docs/router/framework/react/guide/internationalization-i18n.md index cebf8f30a8..0f4fad7eb6 100644 --- a/docs/router/framework/react/guide/internationalization-i18n.md +++ b/docs/router/framework/react/guide/internationalization-i18n.md @@ -284,3 +284,4 @@ export const prerenderRoutes = ['/', '/about'].map((path) => ({ [https://nikuscs.com/blog/13-tanstackstart-i18n/](https://nikuscs.com/blog/13-tanstackstart-i18n/)\*\* - **TanStack Start i18n (blog)** — [https://nikuscs.com/blog/13-tanstackstart-i18n/](https://nikuscs.com/blog/13-tanstackstart-i18n/)## Additional i18n Integration Patterns +```` From 785bd328f6dff68d2c452a01dcf64af1fa7eb6de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BAlio=20M=C3=BChlbauer?= <53458125+juliomuhlbauer@users.noreply.github.com> Date: Thu, 25 Dec 2025 14:53:39 -0300 Subject: [PATCH 06/13] fix req --- .../react/guide/internationalization-i18n.md | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/docs/router/framework/react/guide/internationalization-i18n.md b/docs/router/framework/react/guide/internationalization-i18n.md index 0f4fad7eb6..d5594c202d 100644 --- a/docs/router/framework/react/guide/internationalization-i18n.md +++ b/docs/router/framework/react/guide/internationalization-i18n.md @@ -26,7 +26,7 @@ This pattern relies exclusively on TanStack Router features. It is suitable when Optional path parameters are ideal for implementing locale-aware routing without duplicating routes. ```ts -;/{-$locale}/abotu +/{-$locale}/about ``` This single route matches: @@ -178,24 +178,12 @@ import { paraglideMiddleware } from './paraglide/server' export default { fetch(req: Request) { - return paraglideMiddleware(req, ({ request }) => - handler.fetch(request), + return paraglideMiddleware(req, () => + handler.fetch(req), ) }, } -```ts -import { paraglideMiddleware } from './paraglide/server' - -export default { - fetch(req: Request) { - return paraglideMiddleware(req, ({ request }) => - handler.fetch(request), - ) - }, -} -``` - Set the `` attribute from Paraglide: ```tsx From cfa5eb7f8c7fcfa31a6217700e6d9ca23ca3d96a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BAlio=20M=C3=BChlbauer?= <53458125+juliomuhlbauer@users.noreply.github.com> Date: Thu, 25 Dec 2025 14:54:29 -0300 Subject: [PATCH 07/13] remove duplicated --- .../framework/react/guide/internationalization-i18n.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/docs/router/framework/react/guide/internationalization-i18n.md b/docs/router/framework/react/guide/internationalization-i18n.md index d5594c202d..10166947f6 100644 --- a/docs/router/framework/react/guide/internationalization-i18n.md +++ b/docs/router/framework/react/guide/internationalization-i18n.md @@ -269,7 +269,4 @@ export const prerenderRoutes = ['/', '/about'].map((path) => ({ ### use-intl (TanStack Start integration) -[https://nikuscs.com/blog/13-tanstackstart-i18n/](https://nikuscs.com/blog/13-tanstackstart-i18n/)\*\* - -- **TanStack Start i18n (blog)** — [https://nikuscs.com/blog/13-tanstackstart-i18n/](https://nikuscs.com/blog/13-tanstackstart-i18n/)## Additional i18n Integration Patterns -```` +[https://nikuscs.com/blog/13-tanstackstart-i18n/](https://nikuscs.com/blog/13-tanstackstart-i18n/) \ No newline at end of file From 9206d4709bad151f0ff61a4a532c7185c405e66d Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Thu, 25 Dec 2025 17:55:48 +0000 Subject: [PATCH 08/13] ci: apply automated fixes --- .../framework/react/guide/internationalization-i18n.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/router/framework/react/guide/internationalization-i18n.md b/docs/router/framework/react/guide/internationalization-i18n.md index 10166947f6..146e869081 100644 --- a/docs/router/framework/react/guide/internationalization-i18n.md +++ b/docs/router/framework/react/guide/internationalization-i18n.md @@ -26,7 +26,7 @@ This pattern relies exclusively on TanStack Router features. It is suitable when Optional path parameters are ideal for implementing locale-aware routing without duplicating routes. ```ts -/{-$locale}/about +;/{-$locale}/abotu ``` This single route matches: @@ -269,4 +269,5 @@ export const prerenderRoutes = ['/', '/about'].map((path) => ({ ### use-intl (TanStack Start integration) -[https://nikuscs.com/blog/13-tanstackstart-i18n/](https://nikuscs.com/blog/13-tanstackstart-i18n/) \ No newline at end of file +[https://nikuscs.com/blog/13-tanstackstart-i18n/](https://nikuscs.com/blog/13-tanstackstart-i18n/) +```` From 02a7f188ff212285790e18b74d6f241d26ca8eae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BAlio=20M=C3=BChlbauer?= <53458125+juliomuhlbauer@users.noreply.github.com> Date: Thu, 25 Dec 2025 14:58:14 -0300 Subject: [PATCH 09/13] fix duplicated --- .../react/guide/internationalization-i18n.md | 64 ++++++------------- 1 file changed, 21 insertions(+), 43 deletions(-) diff --git a/docs/router/framework/react/guide/internationalization-i18n.md b/docs/router/framework/react/guide/internationalization-i18n.md index 146e869081..b9c5fe46dd 100644 --- a/docs/router/framework/react/guide/internationalization-i18n.md +++ b/docs/router/framework/react/guide/internationalization-i18n.md @@ -26,15 +26,15 @@ This pattern relies exclusively on TanStack Router features. It is suitable when Optional path parameters are ideal for implementing locale-aware routing without duplicating routes. ```ts -;/{-$locale}/abotu -``` +/{-$locale}/about +```` This single route matches: -- `/about` (default locale) -- `/en/about` -- `/fr/about` -- `/es/about` +* `/about` (default locale) +* `/en/about` +* `/fr/about` +* `/es/about` ### Prefix-based i18n @@ -102,8 +102,6 @@ function isLocale(value?: string): value is Locale { --- ---- - ## i18n Library Integration Patterns TanStack Router is **library-agnostic**. You can integrate any i18n solution by mapping locale state to routing behavior. @@ -116,9 +114,9 @@ Below is a recommended pattern using **Paraglide**. This pattern combines TanStack Router with a client-side i18n library. It is suitable when: -- You want type-safe translations -- You want localized URLs -- You do not need server-side rendering +* You want type-safe translations +* You want localized URLs +* You do not need server-side rendering ### TanStack Router + Paraglide (Client-only) @@ -162,9 +160,9 @@ const router = createRouter({ This pattern integrates i18n at the routing and server layers. It is suitable when: -- You use TanStack Start -- You need SSR or streaming -- You want locale-aware redirects and metadata +* You use TanStack Start +* You need SSR or streaming +* You want locale-aware redirects and metadata ### TanStack Start + Paraglide @@ -173,7 +171,7 @@ This pattern integrates i18n at the routing and server layers. It is suitable wh ### Server Middleware (SSR) -````ts +```ts import { paraglideMiddleware } from './paraglide/server' export default { @@ -183,8 +181,9 @@ export default { ) }, } +``` -Set the `` attribute from Paraglide: +### HTML Language Attribute ```tsx import { getLocale } from '../paraglide/runtime' @@ -192,7 +191,6 @@ import { getLocale } from '../paraglide/runtime' ``` - --- ## Offline-safe Redirects @@ -223,34 +221,13 @@ import { Locale } from '@/paraglide/runtime' This guarantees: -- No missing translations -- Full type safety -- Compiler feedback for routing mistakes +* No missing translations +* Full type safety +* Compiler feedback for routing mistakes --- -### HTML Language Attribute - -```tsx -import { getLocale } from '../paraglide/runtime' - - -``` - -### Offline-safe Redirects - -```ts -import { shouldRedirect } from '../paraglide/runtime' - -beforeLoad: async () => { - const decision = await shouldRedirect({ url: window.location.href }) - if (decision.redirectUrl) { - throw redirect({ href: decision.redirectUrl.href }) - } -} -``` - -### Prerendering Localized Routes +## Prerendering Localized Routes ```ts import { localizeHref } from './paraglide/runtime' @@ -261,6 +238,8 @@ export const prerenderRoutes = ['/', '/about'].map((path) => ({ })) ``` +--- + ## Additional i18n Integration Patterns ### Intlayer (TanStack Start integration) @@ -270,4 +249,3 @@ export const prerenderRoutes = ['/', '/about'].map((path) => ({ ### use-intl (TanStack Start integration) [https://nikuscs.com/blog/13-tanstackstart-i18n/](https://nikuscs.com/blog/13-tanstackstart-i18n/) -```` From 7e09cc1ca4882d28bd2c0036e4ccb7a9c33870a5 Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Thu, 25 Dec 2025 17:59:25 +0000 Subject: [PATCH 10/13] ci: apply automated fixes --- .../react/guide/internationalization-i18n.md | 36 +++++++++---------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/docs/router/framework/react/guide/internationalization-i18n.md b/docs/router/framework/react/guide/internationalization-i18n.md index b9c5fe46dd..7a27a2ded4 100644 --- a/docs/router/framework/react/guide/internationalization-i18n.md +++ b/docs/router/framework/react/guide/internationalization-i18n.md @@ -26,15 +26,15 @@ This pattern relies exclusively on TanStack Router features. It is suitable when Optional path parameters are ideal for implementing locale-aware routing without duplicating routes. ```ts -/{-$locale}/about -```` +;/{-$locale}/abotu +``` This single route matches: -* `/about` (default locale) -* `/en/about` -* `/fr/about` -* `/es/about` +- `/about` (default locale) +- `/en/about` +- `/fr/about` +- `/es/about` ### Prefix-based i18n @@ -114,9 +114,9 @@ Below is a recommended pattern using **Paraglide**. This pattern combines TanStack Router with a client-side i18n library. It is suitable when: -* You want type-safe translations -* You want localized URLs -* You do not need server-side rendering +- You want type-safe translations +- You want localized URLs +- You do not need server-side rendering ### TanStack Router + Paraglide (Client-only) @@ -160,9 +160,9 @@ const router = createRouter({ This pattern integrates i18n at the routing and server layers. It is suitable when: -* You use TanStack Start -* You need SSR or streaming -* You want locale-aware redirects and metadata +- You use TanStack Start +- You need SSR or streaming +- You want locale-aware redirects and metadata ### TanStack Start + Paraglide @@ -176,9 +176,7 @@ import { paraglideMiddleware } from './paraglide/server' export default { fetch(req: Request) { - return paraglideMiddleware(req, () => - handler.fetch(req), - ) + return paraglideMiddleware(req, () => handler.fetch(req)) }, } ``` @@ -188,7 +186,7 @@ export default { ```tsx import { getLocale } from '../paraglide/runtime' - +; ``` --- @@ -221,9 +219,9 @@ import { Locale } from '@/paraglide/runtime' This guarantees: -* No missing translations -* Full type safety -* Compiler feedback for routing mistakes +- No missing translations +- Full type safety +- Compiler feedback for routing mistakes --- From 02c8646ac54843fb033f008cc7a623a624f71f43 Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Thu, 25 Dec 2025 18:00:34 +0000 Subject: [PATCH 11/13] ci: apply automated fixes (attempt 2/3) --- docs/router/framework/react/guide/internationalization-i18n.md | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/router/framework/react/guide/internationalization-i18n.md b/docs/router/framework/react/guide/internationalization-i18n.md index 7a27a2ded4..4939771777 100644 --- a/docs/router/framework/react/guide/internationalization-i18n.md +++ b/docs/router/framework/react/guide/internationalization-i18n.md @@ -185,7 +185,6 @@ export default { ```tsx import { getLocale } from '../paraglide/runtime' - ; ``` From 813357cadcf279a634478c2f8887b05e0eeb738e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BAlio=20M=C3=BChlbauer?= <53458125+juliomuhlbauer@users.noreply.github.com> Date: Thu, 25 Dec 2025 15:06:03 -0300 Subject: [PATCH 12/13] fix spelling --- docs/router/framework/react/guide/internationalization-i18n.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/router/framework/react/guide/internationalization-i18n.md b/docs/router/framework/react/guide/internationalization-i18n.md index 4939771777..1738421f3a 100644 --- a/docs/router/framework/react/guide/internationalization-i18n.md +++ b/docs/router/framework/react/guide/internationalization-i18n.md @@ -26,7 +26,7 @@ This pattern relies exclusively on TanStack Router features. It is suitable when Optional path parameters are ideal for implementing locale-aware routing without duplicating routes. ```ts -;/{-$locale}/abotu +;/{-$locale}/about ``` This single route matches: From 1b99807c1875ecbbf0f63014c3227170345eaf33 Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Thu, 25 Dec 2025 18:07:07 +0000 Subject: [PATCH 13/13] ci: apply automated fixes --- docs/router/framework/react/guide/internationalization-i18n.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/router/framework/react/guide/internationalization-i18n.md b/docs/router/framework/react/guide/internationalization-i18n.md index 1738421f3a..4939771777 100644 --- a/docs/router/framework/react/guide/internationalization-i18n.md +++ b/docs/router/framework/react/guide/internationalization-i18n.md @@ -26,7 +26,7 @@ This pattern relies exclusively on TanStack Router features. It is suitable when Optional path parameters are ideal for implementing locale-aware routing without duplicating routes. ```ts -;/{-$locale}/about +;/{-$locale}/abotu ``` This single route matches: