Merge pull request #994 from matrix-org/revert-989-add-language-picker-labels
Revert "add labels to language picker"
This commit is contained in:
commit
3c02b70eb7
2 changed files with 13 additions and 15 deletions
|
@ -40,7 +40,14 @@ export default class LanguageDropdown extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillMount() {
|
componentWillMount() {
|
||||||
languageHandler.getAllLanguagesFromJson().then((langs) => {
|
languageHandler.getAllLanguageKeysFromJson().then((langKeys) => {
|
||||||
|
const langs = [];
|
||||||
|
langKeys.forEach((languageKey) => {
|
||||||
|
langs.push({
|
||||||
|
value: languageKey,
|
||||||
|
label: _t(languageKey)
|
||||||
|
});
|
||||||
|
});
|
||||||
langs.sort(function(a, b){
|
langs.sort(function(a, b){
|
||||||
if(a.label < b.label) return -1;
|
if(a.label < b.label) return -1;
|
||||||
if(a.label > b.label) return 1;
|
if(a.label > b.label) return 1;
|
||||||
|
|
|
@ -133,7 +133,7 @@ export function setLanguage(preferredLangs) {
|
||||||
throw new Error("Unable to find an appropriate language");
|
throw new Error("Unable to find an appropriate language");
|
||||||
}
|
}
|
||||||
|
|
||||||
return getLanguage(i18nFolder + availLangs[langToUse].fileName);
|
return getLanguage(i18nFolder + availLangs[langToUse]);
|
||||||
}).then((langData) => {
|
}).then((langData) => {
|
||||||
counterpart.registerTranslations(langToUse, langData);
|
counterpart.registerTranslations(langToUse, langData);
|
||||||
counterpart.setLocale(langToUse);
|
counterpart.setLocale(langToUse);
|
||||||
|
@ -142,25 +142,16 @@ export function setLanguage(preferredLangs) {
|
||||||
|
|
||||||
// Set 'en' as fallback language:
|
// Set 'en' as fallback language:
|
||||||
if (langToUse != "en") {
|
if (langToUse != "en") {
|
||||||
return getLanguage(i18nFolder + availLangs['en'].fileName);
|
return getLanguage(i18nFolder + availLangs['en']);
|
||||||
}
|
}
|
||||||
}).then((langData) => {
|
}).then((langData) => {
|
||||||
if (langData) counterpart.registerTranslations('en', langData);
|
if (langData) counterpart.registerTranslations('en', langData);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export function getAllLanguagesFromJson() {
|
export function getAllLanguageKeysFromJson() {
|
||||||
return getLangsJson().then((langsObject) => {
|
return getLangsJson().then((langs) => {
|
||||||
var langs = [];
|
return Object.keys(langs);
|
||||||
for (var langKey in langsObject) {
|
|
||||||
if (langsObject.hasOwnProperty(langKey)) {
|
|
||||||
langs.push({
|
|
||||||
'value': langKey,
|
|
||||||
'label': langsObject[langKey].label
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return langs;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue