mirror of
https://github.com/Unleash/unleash.git
synced 2025-02-04 00:18:01 +01:00
fix(locale): Use navigator.language as default locale.
This commit is contained in:
parent
b744368720
commit
d471abbbb0
@ -26,9 +26,7 @@ export default class ShowUserComponent extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateLocale() {
|
updateLocale() {
|
||||||
const locale = this.props.location
|
const locale = (this.props.location && this.props.location.locale) || navigator.language;
|
||||||
? this.props.location.locale
|
|
||||||
: this.possibleLocales[this.possibleLocales.length - 1];
|
|
||||||
let index = this.possibleLocales.findIndex(v => v.value === locale);
|
let index = this.possibleLocales.findIndex(v => v.value === locale);
|
||||||
index = (index + 1) % this.possibleLocales.length;
|
index = (index + 1) % this.possibleLocales.length;
|
||||||
this.props.updateSettingLocation('locale', this.possibleLocales[index].value);
|
this.props.updateSettingLocation('locale', this.possibleLocales[index].value);
|
||||||
@ -36,9 +34,7 @@ export default class ShowUserComponent extends React.Component {
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
const email = this.props.profile ? this.props.profile.email : '';
|
const email = this.props.profile ? this.props.profile.email : '';
|
||||||
const locale = this.props.location
|
const locale = (this.props.location && this.props.location.locale) || navigator.language;
|
||||||
? this.props.location.locale
|
|
||||||
: this.possibleLocales[this.possibleLocales.length - 1].value;
|
|
||||||
let foundLocale = this.possibleLocales.find(l => l.value === locale);
|
let foundLocale = this.possibleLocales.find(l => l.value === locale);
|
||||||
const imageUrl = email ? this.props.profile.imageUrl : 'public/unknown-user.png';
|
const imageUrl = email ? this.props.profile.imageUrl : 'public/unknown-user.png';
|
||||||
const imageLocale = foundLocale ? `public/${foundLocale.image}.png` : `public/unknown-locale.png`;
|
const imageLocale = foundLocale ? `public/${foundLocale.image}.png` : `public/unknown-locale.png`;
|
||||||
|
Loading…
Reference in New Issue
Block a user