Skip to content

Commit

Permalink
⚡ feat: add language search params
Browse files Browse the repository at this point in the history
  • Loading branch information
kms0219kms committed Nov 23, 2023
1 parent e8b0ec0 commit bd6e7f4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
8 changes: 5 additions & 3 deletions src/comingsoon.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useEffect } from "react";

import { Trans, useTranslation } from "react-i18next";
import { useSearchParams } from "react-router-dom";

import {
appCSS,
headerCSS,
Expand All @@ -20,11 +21,12 @@ import text from "./assets/text.svg";

export default function ComingSoon() {
const { t, i18n } = useTranslation();
const [searchParams] = useSearchParams();

useEffect(() => {
i18n.changeLanguage(navigator.language.split("-")[0]);
i18n.changeLanguage(searchParams.get('lang') || navigator.language.split("-")[0]);

document.documentElement.lang = navigator.language.split("-")[0];
document.documentElement.lang = searchParams.get('lang') || navigator.language.split("-")[0];
document.title = i18n.t("comingsoon.title").replace("<1>", "").replace("</1>", "");
}, [i18n]);

Expand Down
8 changes: 5 additions & 3 deletions src/maintenance.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useEffect } from "react";

import { Trans, useTranslation } from "react-i18next";
import { useSearchParams } from "react-router-dom";

import {
appCSS,
headerCSS,
Expand All @@ -20,11 +21,12 @@ import text from "./assets/text.svg";

export default function Maintenance() {
const { t, i18n } = useTranslation();
const [searchParams] = useSearchParams();

useEffect(() => {
i18n.changeLanguage(navigator.language.split("-")[0]);
i18n.changeLanguage(searchParams.get('lang') || navigator.language.split("-")[0]);

document.documentElement.lang = navigator.language.split("-")[0];
document.documentElement.lang = searchParams.get('lang') || navigator.language.split("-")[0];
document.title = i18n.t("maintenance.title").replace("<1>", "").replace("</1>", "");
}, [i18n]);

Expand Down

0 comments on commit bd6e7f4

Please sign in to comment.