Skip to content

Commit

Permalink
MM-13680 Modify return value of getLanguages (mattermost#2268)
Browse files Browse the repository at this point in the history
* Modify return value of getLanguages

* Refactor to avoid looping twice
  • Loading branch information
kaakaa authored and enahum committed Jan 27, 2019
1 parent 2b8becb commit 4a6d79a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions i18n/i18n.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,12 @@ export function getLanguages() {
if (!config.AvailableLocales) {
return getAllLanguages();
}

return config.AvailableLocales.split(',').filter((l) => languages[l]).map((l) => languages[l]);
return config.AvailableLocales.split(',').reduce((result, l) => {
if (languages[l]) {
result[l] = languages[l];
}
return result;
}, {});
}

export function getLanguageInfo(locale) {
Expand Down

0 comments on commit 4a6d79a

Please sign in to comment.