phanpy/src/utils/locale-match.jsx

17 lines
365 B
React
Raw Normal View History

import { match } from '@formatjs/intl-localematcher';
2023-06-11 15:28:12 +00:00
import mem from 'mem';
2023-06-11 15:28:12 +00:00
function _localeMatch(...args) {
// Wrap in try/catch because localeMatcher throws on invalid locales
try {
return match(...args);
} catch (e) {
return false;
}
}
2023-06-11 15:28:12 +00:00
const localeMatch = mem(_localeMatch, {
cacheKey: (args) => args.join(),
});
export default localeMatch;