From 0e3f3e30134d603e85a8024fdaa1a728a33b1452 Mon Sep 17 00:00:00 2001 From: Joel Marcey Date: Thu, 12 Apr 2018 08:45:02 -0700 Subject: [PATCH] Fix header nav display for current language (#550) 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. --- lib/core/nav/HeaderNav.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/core/nav/HeaderNav.js b/lib/core/nav/HeaderNav.js index 522462057951..229bdfc57610 100644 --- a/lib/core/nav/HeaderNav.js +++ b/lib/core/nav/HeaderNav.js @@ -24,7 +24,6 @@ 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' @@ -32,7 +31,7 @@ class LanguageDropDown extends React.Component { // 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 => (
  • {lang.name} @@ -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(