-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #139 from ubilabs/feat/i18n-language-switcher
feat(i18n): language switcher
- Loading branch information
Showing
4 changed files
with
35 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
{ | ||
"layerSelector.main": "Haupt", | ||
"layerSelector.compare": "Vergleich" | ||
"layerSelector.compare": "Vergleich", | ||
"language.en": "Englisch", | ||
"language.de": "Deutsch" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
{ | ||
"layerSelector.main": "Main", | ||
"layerSelector.compare": "Compare" | ||
"layerSelector.compare": "Compare", | ||
"language.en": "English", | ||
"language.de": "German" | ||
} |
25 changes: 25 additions & 0 deletions
25
src/scripts/components/language-selector/language-selector.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import React, {FunctionComponent} from 'react'; | ||
import {FormattedMessage} from 'react-intl'; | ||
import {useDispatch} from 'react-redux'; | ||
|
||
import setLanguageAction, {Language} from '../../actions/set-language'; | ||
|
||
const languages = Object.values(Language); | ||
|
||
const LanguageSelector: FunctionComponent<{}> = () => { | ||
const dispatch = useDispatch(); | ||
const setLanguage = (language: Language) => | ||
dispatch(setLanguageAction(language)); | ||
|
||
return ( | ||
<ul> | ||
{languages.map(language => ( | ||
<li key={language} onClick={() => setLanguage(language)}> | ||
<FormattedMessage id={`language.${language}`} /> | ||
</li> | ||
))} | ||
</ul> | ||
); | ||
}; | ||
|
||
export default LanguageSelector; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters