phanpy/src/utils/locale-match.js
Lim Chee Aun 80d4a45a65 s/jsx/js extension
Somehow vscode refactor "Move to a new file" preserves the jsx extension
2024-09-23 12:43:55 +08:00

16 lines
380 B
JavaScript

import { match } from '@formatjs/intl-localematcher';
import mem from './mem';
function _localeMatch(...args) {
// Wrap in try/catch because localeMatcher throws on invalid locales
try {
return match(...args);
} catch (e) {
const defaultLocale = args[2];
return defaultLocale || false;
}
}
const localeMatch = mem(_localeMatch);
export default localeMatch;