1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-11 00:08:30 +01:00

fix(locale): Use navigator.language as default locale.

This commit is contained in:
Dave Dunkin 2018-10-20 11:31:24 -07:00
parent b744368720
commit d471abbbb0

View File

@ -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`;