Client - change language on dropdown change

This commit is contained in:
Sam 2019-09-08 16:38:44 +02:00
parent 44d0c36485
commit 97934f8ffe

View File

@ -1,4 +1,5 @@
import React, { Component } from 'react' import React, { Component } from 'react'
import i18next from 'i18next'
import { ReactComponent as EnFlag } from '../../images/flags/en.svg' import { ReactComponent as EnFlag } from '../../images/flags/en.svg'
import { ReactComponent as FrFlag } from '../../images/flags/fr.svg' import { ReactComponent as FrFlag } from '../../images/flags/fr.svg'
@ -26,10 +27,13 @@ class Dropdown extends Component {
} }
selectLanguage(name) { selectLanguage(name) {
if (name !== this.state.selected) {
i18next.changeLanguage(name)
this.setState({ this.setState({
selected: name, selected: name,
}) })
} }
}
toggleDropdown() { toggleDropdown() {
this.setState(prevState => ({ this.setState(prevState => ({