From d471abbbb0d1f7eeb621c320fc9656add6a01fba Mon Sep 17 00:00:00 2001 From: Dave Dunkin Date: Sat, 20 Oct 2018 11:31:24 -0700 Subject: [PATCH] fix(locale): Use navigator.language as default locale. --- frontend/src/component/user/show-user-component.jsx | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/frontend/src/component/user/show-user-component.jsx b/frontend/src/component/user/show-user-component.jsx index 75fec9fa97..9b2d704b9b 100644 --- a/frontend/src/component/user/show-user-component.jsx +++ b/frontend/src/component/user/show-user-component.jsx @@ -26,9 +26,7 @@ export default class ShowUserComponent extends React.Component { } updateLocale() { - const locale = this.props.location - ? this.props.location.locale - : this.possibleLocales[this.possibleLocales.length - 1]; + const locale = (this.props.location && this.props.location.locale) || navigator.language; let index = this.possibleLocales.findIndex(v => v.value === locale); index = (index + 1) % this.possibleLocales.length; this.props.updateSettingLocation('locale', this.possibleLocales[index].value); @@ -36,9 +34,7 @@ export default class ShowUserComponent extends React.Component { render() { const email = this.props.profile ? this.props.profile.email : ''; - const locale = this.props.location - ? this.props.location.locale - : this.possibleLocales[this.possibleLocales.length - 1].value; + const locale = (this.props.location && this.props.location.locale) || navigator.language; let foundLocale = this.possibleLocales.find(l => l.value === locale); const imageUrl = email ? this.props.profile.imageUrl : 'public/unknown-user.png'; const imageLocale = foundLocale ? `public/${foundLocale.image}.png` : `public/unknown-locale.png`;