Skip to content

Internationalization (i18n) #549

Answered by binajmen
binajmen asked this question in Q&A
Discussion options

You must be logged in to vote

Thanks for sharing @nirtamir2.

In the end I did manage to make it work quite nicely :) I'm using the lang param in the route. Unfortunately, as useParams() does not work in root (not surrounded by <Route>), I had to extract the local from location.pathname.

// @refresh reload
import { useLocation } from "@solidjs/router";
import { Suspense } from "solid-js";
import {
  Body,
  ErrorBoundary,
  FileRoutes,
  Head,
  Html,
  Meta,
  Routes,
  Scripts,
  Title,
} from "solid-start";
import { I18nProvider } from "~/i18n";
import { dict } from "~/i18n-dict";
import "./root.css";

function extractLocale(path: string, defaultLocale = "en") {
  const segments = path.split("/");
  let locale = seg…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by binajmen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants