Make current language more accurate

Make it reflect reality if it's been taken from the browser langs
by just getting what was saet in counterpart rather than the saved
setting.

Also fix style.
This commit is contained in:
David Baker 2017-05-25 19:53:27 +01:00
parent be4944a4b6
commit e7fbf889fa
2 changed files with 10 additions and 12 deletions

View file

@ -202,16 +202,10 @@ module.exports = React.createClass({
this._syncedSettings = syncedSettings;
this._localSettings = UserSettingsStore.getLocalSettings();
if (!this._localSettings.hasOwnProperty('language')) {
const language = languageHandler.normalizeLanguageKey(languageHandler.getLanguageFromBrowser());
this.setState({
Language: language
});
} else {
this.setState({
Language: this._localSettings.language
});
}
this.setState({
language: languageHandler.getCurrentLanguage(),
});
},
componentDidMount: function() {
@ -551,7 +545,7 @@ module.exports = React.createClass({
onLanguageChange: function(l) {
UserSettingsStore.setLocalSetting('language', l);
this.setState({
Language: l,
language: l,
});
PlatformPeg.get().reload();
},
@ -562,7 +556,7 @@ module.exports = React.createClass({
<label htmlFor="languageSelector">{_t('Interface Language')}</label>
<LanguageDropdown ref="language" onOptionChange={this.onLanguageChange}
className="mx_UserSettings_language"
value={this.state.Language}
value={this.state.language}
/>
</div>;
},

View file

@ -116,6 +116,10 @@ export function normalizeLanguageKey(language) {
return language.toLowerCase().replace("_","-");
};
export function getCurrentLanguage() {
return counterpart.getLocale();
}
function getLangsJson() {
const deferred = q.defer();