mirror of
https://github.com/element-hq/element-web
synced 2024-11-27 03:36:07 +03:00
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:
parent
be4944a4b6
commit
e7fbf889fa
2 changed files with 10 additions and 12 deletions
|
@ -202,16 +202,10 @@ module.exports = React.createClass({
|
||||||
this._syncedSettings = syncedSettings;
|
this._syncedSettings = syncedSettings;
|
||||||
|
|
||||||
this._localSettings = UserSettingsStore.getLocalSettings();
|
this._localSettings = UserSettingsStore.getLocalSettings();
|
||||||
if (!this._localSettings.hasOwnProperty('language')) {
|
|
||||||
const language = languageHandler.normalizeLanguageKey(languageHandler.getLanguageFromBrowser());
|
|
||||||
this.setState({
|
this.setState({
|
||||||
Language: language
|
language: languageHandler.getCurrentLanguage(),
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
this.setState({
|
|
||||||
Language: this._localSettings.language
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
componentDidMount: function() {
|
componentDidMount: function() {
|
||||||
|
@ -551,7 +545,7 @@ module.exports = React.createClass({
|
||||||
onLanguageChange: function(l) {
|
onLanguageChange: function(l) {
|
||||||
UserSettingsStore.setLocalSetting('language', l);
|
UserSettingsStore.setLocalSetting('language', l);
|
||||||
this.setState({
|
this.setState({
|
||||||
Language: l,
|
language: l,
|
||||||
});
|
});
|
||||||
PlatformPeg.get().reload();
|
PlatformPeg.get().reload();
|
||||||
},
|
},
|
||||||
|
@ -562,7 +556,7 @@ module.exports = React.createClass({
|
||||||
<label htmlFor="languageSelector">{_t('Interface Language')}</label>
|
<label htmlFor="languageSelector">{_t('Interface Language')}</label>
|
||||||
<LanguageDropdown ref="language" onOptionChange={this.onLanguageChange}
|
<LanguageDropdown ref="language" onOptionChange={this.onLanguageChange}
|
||||||
className="mx_UserSettings_language"
|
className="mx_UserSettings_language"
|
||||||
value={this.state.Language}
|
value={this.state.language}
|
||||||
/>
|
/>
|
||||||
</div>;
|
</div>;
|
||||||
},
|
},
|
||||||
|
|
|
@ -116,6 +116,10 @@ export function normalizeLanguageKey(language) {
|
||||||
return language.toLowerCase().replace("_","-");
|
return language.toLowerCase().replace("_","-");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export function getCurrentLanguage() {
|
||||||
|
return counterpart.getLocale();
|
||||||
|
}
|
||||||
|
|
||||||
function getLangsJson() {
|
function getLangsJson() {
|
||||||
const deferred = q.defer();
|
const deferred = q.defer();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue