From: Daniel Karbach Date: Fri, 13 Jan 2023 23:54:37 +0000 (+0100) Subject: translate tech title X-Git-Url: https://git.localhorst.tv/?a=commitdiff_plain;h=a94dda65a823a1f191ffbc3981448adfae270fcc;p=alttp.git translate tech title --- diff --git a/resources/js/components/pages/Technique.js b/resources/js/components/pages/Technique.js index 19b56b7..8c202ed 100644 --- a/resources/js/components/pages/Technique.js +++ b/resources/js/components/pages/Technique.js @@ -1,5 +1,6 @@ import axios from 'axios'; import React, { useEffect, useState } from 'react'; +import { withTranslation } from 'react-i18next'; import { useParams } from 'react-router-dom'; import ErrorBoundary from '../common/ErrorBoundary'; @@ -7,6 +8,8 @@ import ErrorMessage from '../common/ErrorMessage'; import Loading from '../common/Loading'; import NotFound from '../pages/NotFound'; import Detail from '../techniques/Detail'; +import { getTranslation } from '../../helpers/Technique'; +import i18n from '../../i18n'; const Technique = () => { const params = useParams(); @@ -25,7 +28,6 @@ const Technique = () => { setError(null); setLoading(false); setTechnique(response.data); - window.document.title = response.data.title; }) .catch(error => { setError(error); @@ -37,6 +39,12 @@ const Technique = () => { }; }, [name]); + useEffect(() => { + if (technique) { + window.document.title = getTranslation(technique, 'title', i18n.language); + } + }, [technique, i18n.language]); + if (loading) { return ; } @@ -54,4 +62,4 @@ const Technique = () => { ; }; -export default Technique; +export default withTranslation()(Technique);