Translate done and determinated the user's language

This commit is contained in:
2021-10-15 15:46:50 -03:00
parent d9f4948e53
commit 95bae8a765
5 changed files with 93 additions and 34 deletions

View File

@@ -7,10 +7,11 @@ import Victory from "./components/Hangman/PuzzleWord/Victory";
import Defeat from "./components/Hangman/PuzzleWord/Defeat";
import Loading from "./components/Loading";
import AlmacenateCurrentScore from "./components/Scripts/AlmacenateCurrentScore";
import DetermineUserLanguage from "./components/Scripts/DetermineUserLanguage";
function App() {
const [language, setLanguage] = useState('spanish')
const [language, setLanguage] = useState('')
const [category, setCategory] = useState(false)
const [currentScore, setCurrentScore] = useState(0)
@@ -24,12 +25,29 @@ function App() {
React.useEffect(() => {
DetermineUserLanguage(setLanguage)
if (localStorage.getItem('currentScore')) {
setCurrentScore(localStorage.getItem('currentScore'))
localStorage.removeItem('currentScore')
}
const titleAPP = {
english: 'Hangman game',
spanish: 'Ahorcado'
}
if (language === 'english') {
document.title = titleAPP.english
}
if (language === 'spanish') {
document.title = titleAPP.spanish
}
})
if (isVictory || isDefeat) {
@@ -42,6 +60,8 @@ function App() {
}, 3000)
}
return (
<>
<Header language={language}/>
@@ -57,7 +77,12 @@ function App() {
<div className='column-2'>
<CurrentScore currentScore={currentScore} />
<CurrentScore
currentScore={currentScore}
language={language}
/>
{!displayApp ? <Loading /> : null }