mirror of
https://github.com/Findus23/lw1.at.git
synced 2024-09-10 05:13:46 +02:00
25 lines
593 B
TypeScript
25 lines
593 B
TypeScript
import type {Language} from "./types";
|
|
|
|
export function defaultLanguage(): Language {
|
|
const lang = navigator.language.toLowerCase()
|
|
if (lang.includes("de")) {
|
|
return "de"
|
|
}
|
|
return "en"
|
|
}
|
|
|
|
export function redirect(): void {
|
|
const l = window.location
|
|
const imprintName = {"de": "impressum", "en": "imprint"}
|
|
|
|
const currentPath = l.pathname
|
|
const lang = defaultLanguage()
|
|
if (currentPath.startsWith("/i")) {
|
|
l.replace("/" + lang + "/" + imprintName[lang])
|
|
return
|
|
|
|
}
|
|
l.replace("/" + defaultLanguage() + l.pathname)
|
|
}
|
|
|
|
redirect()
|