mirror of
https://github.com/FranP-code/Hangman-game-with-React.git
synced 2025-10-13 00:42:32 +00:00
Translate done and determinated the user's language
This commit is contained in:
29
src/App.js
29
src/App.js
@@ -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 }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user