page title on language change
This commit is contained in:
parent
f5ecf91b9c
commit
7d4c280cc9
18
src/App.tsx
18
src/App.tsx
|
|
@ -2,7 +2,7 @@
|
||||||
import { Routes, Route, useLocation } from "react-router-dom";
|
import { Routes, Route, useLocation } from "react-router-dom";
|
||||||
import { AnimatePresence } from "framer-motion";
|
import { AnimatePresence } from "framer-motion";
|
||||||
import ScrollToTop from "./hooks/ScrollToTop";
|
import ScrollToTop from "./hooks/ScrollToTop";
|
||||||
import { changeLanguage } from "i18next";
|
// import { changeLanguage } from "i18next";
|
||||||
|
|
||||||
// Styles
|
// Styles
|
||||||
import "swiper/swiper.css";
|
import "swiper/swiper.css";
|
||||||
|
|
@ -24,6 +24,7 @@ import NotFound404 from "./pages/NotFound404";
|
||||||
import Header from "./components/header/Header";
|
import Header from "./components/header/Header";
|
||||||
import Footer from "./components/footer/Footer";
|
import Footer from "./components/footer/Footer";
|
||||||
import { Api } from "./api/Api";
|
import { Api } from "./api/Api";
|
||||||
|
import { useEffect } from "react";
|
||||||
|
|
||||||
const App = () => {
|
const App = () => {
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
|
|
@ -33,6 +34,21 @@ const App = () => {
|
||||||
// changeLanguage(language);
|
// changeLanguage(language);
|
||||||
// }, [language]);
|
// }, [language]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
try {
|
||||||
|
const title = document.querySelector("title") as any;
|
||||||
|
language === "EN"
|
||||||
|
? (title.innerText = "Turkmenistan News Portal")
|
||||||
|
: language === "RU"
|
||||||
|
? (title.innerText = "Туркменистан новостной портал")
|
||||||
|
: language === "TM"
|
||||||
|
? (title.innerText = "Turkmenistan habarlar portaly")
|
||||||
|
: "Turkmenistan habarlar portaly";
|
||||||
|
} catch (err) {
|
||||||
|
console.log(err);
|
||||||
|
}
|
||||||
|
}, [language]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ScrollToTop>
|
<ScrollToTop>
|
||||||
<div className="App">
|
<div className="App">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue