Skip to content

Commit

Permalink
fix(util/i18n): Memoize language options
Browse files Browse the repository at this point in the history
  • Loading branch information
binh-dam-ibigroup committed Mar 29, 2023
1 parent e24f246 commit d89b49c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/util/i18n.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import clone from 'clone'
import flatten from 'flat'
import memoize from 'lodash.memoize'

// deepmerge must be imported via `require`: see https://github.com/TehShrike/deepmerge#include
const merge = require('deepmerge')
Expand Down Expand Up @@ -63,7 +64,7 @@ export function getConfigLocales(configLanguages) {
* @param {*} configLanguages The configured languages.
* @returns An array of the supported locale ids if 2 or more are configured, null otherwise.
*/
export function getLanguageOptions(configLanguages) {
export const getLanguageOptions = memoize((configLanguages) => {
const filteredKeys =
(configLanguages &&
Object.keys(configLanguages).filter(
Expand All @@ -77,7 +78,7 @@ export function getLanguageOptions(configLanguages) {
filteredLanguages[key] = configLanguages[key]
})
return filteredLanguages
}
})

/**
* Loads in all localized strings from @opentripplanner packages.
Expand Down

0 comments on commit d89b49c

Please sign in to comment.