Highlight current i18n language in navbar
Change-Id: Icce66e362286de317245f9f2de70284471631209 Closes-Bug: #1669485
This commit is contained in:
parent
e8eb44c517
commit
3d038f2887
|
@ -22,9 +22,14 @@ class I18nDropdown extends React.Component {
|
|||
const langList = Object.keys(configLanguages).sort((a , b) =>
|
||||
configLanguages[a] > configLanguages[b]);
|
||||
|
||||
const enabledLang = this.props.language;
|
||||
|
||||
return langList.map((lang) => {
|
||||
const active = enabledLang === lang;
|
||||
return (MESSAGES[lang] || lang === 'en') ? (
|
||||
<DropdownItem key={`lang-${lang}`} onClick={this.props.chooseLanguage.bind(this, lang)}>
|
||||
<DropdownItem key={`lang-${lang}`}
|
||||
active={active}
|
||||
onClick={this.props.chooseLanguage.bind(this, lang)}>
|
||||
{configLanguages[lang]}
|
||||
</DropdownItem>
|
||||
) : null;
|
||||
|
@ -44,7 +49,14 @@ class I18nDropdown extends React.Component {
|
|||
}
|
||||
|
||||
I18nDropdown.propTypes = {
|
||||
chooseLanguage: React.PropTypes.func.isRequired
|
||||
chooseLanguage: React.PropTypes.func.isRequired,
|
||||
language: React.PropTypes.string
|
||||
};
|
||||
|
||||
const mapStateToProps = (state) => {
|
||||
return {
|
||||
language: state.i18n.get('language', 'en')
|
||||
};
|
||||
};
|
||||
|
||||
const mapDispatchToProps = (dispatch) => {
|
||||
|
@ -53,4 +65,4 @@ const mapDispatchToProps = (dispatch) => {
|
|||
};
|
||||
};
|
||||
|
||||
export default injectIntl(connect(null, mapDispatchToProps)(I18nDropdown));
|
||||
export default injectIntl(connect(mapStateToProps, mapDispatchToProps)(I18nDropdown));
|
||||
|
|
Loading…
Reference in New Issue