mirror of https://github.com/vector-im/riot-web
Move language handling into languageHandler
parent
52420feab0
commit
3aef3b72b5
|
@ -58,13 +58,8 @@ export default class LanguageDropdown extends React.Component {
|
||||||
// If no value is given, we start with the first
|
// If no value is given, we start with the first
|
||||||
// country selected, but our parent component
|
// country selected, but our parent component
|
||||||
// doesn't know this, therefore we do this.
|
// doesn't know this, therefore we do this.
|
||||||
const language = SettingsStore.getValue("language", null, /*excludeDefault:*/true);
|
const language = languageHandler.getUserLanguage();
|
||||||
if (language) {
|
|
||||||
this.props.onOptionChange(language);
|
this.props.onOptionChange(language);
|
||||||
} else {
|
|
||||||
const language = languageHandler.normalizeLanguageKey(languageHandler.getLanguageFromBrowser());
|
|
||||||
this.props.onOptionChange(language);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,6 +56,15 @@ export function newTranslatableError(message: string) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getUserLanguage(): string {
|
||||||
|
const language = SettingsStore.getValue("language", null, /*excludeDefault:*/true);
|
||||||
|
if (language) {
|
||||||
|
return language;
|
||||||
|
} else {
|
||||||
|
return normalizeLanguageKey(getLanguageFromBrowser());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Function which only purpose is to mark that a string is translatable
|
// Function which only purpose is to mark that a string is translatable
|
||||||
// Does not actually do anything. It's helpful for automatic extraction of translatable strings
|
// Does not actually do anything. It's helpful for automatic extraction of translatable strings
|
||||||
export function _td(s: string): string {
|
export function _td(s: string): string {
|
||||||
|
|
Loading…
Reference in New Issue