TanStackT
TanStack6mo ago
3 replies
dangerous-fuchsia

Localised routing? e.g. /en/pricing + /pl/cennik -> should be handled by single file of pricing.tsx

(Paraglide)
How to handle this? I am almost sure I've seen some docs few days ago about it, but spent over an hour looking for it now and cannot git it out.

I have quite few languages so creating dummy files to handle each page in each lang is completely no-go because it will be unmaintainable.
How to approach it?
I sorted out the middleware etc based on Igor Szymanski's repo, but I just cannot get translated paths (important for SEO in multi-lang) working.

    paraglide({
      project: "./project.inlang",
      outdir: "./src/paraglide",
      outputStructure: "message-modules",
      cookieName: "PARAGLIDE_LOCALE",
      strategy: ["url", "cookie", "preferredLanguage", "baseLocale"],
      urlPatterns: [
        // Specific pricing route with translated paths (MUST come first)
        {
          pattern: "/pricing",
          localized: [
            ["en", "/en/pricing"],
            ["de", "/de/preise"], 
            ["pl", "/pl/cennik"],
          ],
        },
        // General wildcard pattern (MUST come last)
        {
          pattern: "/:path(.*)?",
          localized: [
            ["en", "/en/:path(.*)?"],
            ["de", "/de/:path(.*)?"],
            ["pl", "/pl/:path(.*)?"],
          ],
        },
      ],
    }),


/pricing will render but any localised version will keep throwing 404
Was this page helpful?