page title on language change

This commit is contained in:
VividTruthKeeper 2023-02-25 01:01:15 +05:00
parent f5ecf91b9c
commit 7d4c280cc9
1 changed files with 17 additions and 1 deletions

View File

@ -2,7 +2,7 @@
import { Routes, Route, useLocation } from "react-router-dom";
import { AnimatePresence } from "framer-motion";
import ScrollToTop from "./hooks/ScrollToTop";
import { changeLanguage } from "i18next";
// import { changeLanguage } from "i18next";
// Styles
import "swiper/swiper.css";
@ -24,6 +24,7 @@ import NotFound404 from "./pages/NotFound404";
import Header from "./components/header/Header";
import Footer from "./components/footer/Footer";
import { Api } from "./api/Api";
import { useEffect } from "react";
const App = () => {
const location = useLocation();
@ -33,6 +34,21 @@ const App = () => {
// changeLanguage(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 (
<ScrollToTop>
<div className="App">