feat(www): locale specific urls (#12508)
This commit is contained in:
@@ -1,10 +1,14 @@
|
||||
import { For, createSignal } from "solid-js"
|
||||
import { useLocation, useNavigate } from "@solidjs/router"
|
||||
import { Dropdown, DropdownItem } from "~/component/dropdown"
|
||||
import { useLanguage } from "~/context/language"
|
||||
import { route, strip } from "~/lib/language"
|
||||
import "./language-picker.css"
|
||||
|
||||
export function LanguagePicker(props: { align?: "left" | "right" } = {}) {
|
||||
const language = useLanguage()
|
||||
const navigate = useNavigate()
|
||||
const location = useLocation()
|
||||
const [open, setOpen] = createSignal(false)
|
||||
|
||||
return (
|
||||
@@ -21,6 +25,8 @@ export function LanguagePicker(props: { align?: "left" | "right" } = {}) {
|
||||
selected={locale === language.locale()}
|
||||
onClick={() => {
|
||||
language.setLocale(locale)
|
||||
const href = `${route(locale, strip(location.pathname))}${location.search}${location.hash}`
|
||||
if (href !== `${location.pathname}${location.search}${location.hash}`) navigate(href)
|
||||
setOpen(false)
|
||||
}}
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user