Skip to content

Commit

Permalink
Fix header nav display for current language (#550)
Browse files Browse the repository at this point in the history
Even if we were on Spanish pages, it still showed English in the Header nav.
This makes it so that the Header nav shows the currently selected language.
  • Loading branch information
JoelMarcey authored Apr 12, 2018
1 parent 1c94060 commit 0e3f3e3
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/core/nav/HeaderNav.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,14 @@ const Metadata = require('../metadata.js');
// language dropdown nav item for when translations are enabled
class LanguageDropDown extends React.Component {
render() {
let currentLanguage = 'English';
setLanguage(this.props.language || 'en');
let helpTranslateString = translate(
'Help Translate|recruit community translators for your project'
);
// add all enabled languages to dropdown
const enabledLanguages = env.translation
.enabledLanguages()
.filter(lang => lang !== this.props.language)
.filter(lang => lang.tag !== this.props.language)
.map(lang => (
<li key={lang.tag}>
<a href={siteConfig.baseUrl + lang.tag}>{lang.name}</a>
Expand All @@ -42,6 +41,13 @@ class LanguageDropDown extends React.Component {
if (enabledLanguages.length < 1) {
return null;
}

// Get the current language full name for display in the header nav
const currentLanguage = env.translation
.enabledLanguages()
.filter(lang => lang.tag === this.props.language)
.map(lang => lang.name);

// add Crowdin project recruiting link
if (siteConfig.translationRecruitingLink) {
enabledLanguages.push(
Expand Down

0 comments on commit 0e3f3e3

Please sign in to comment.