isLocale.js 313 B

1234567891011
  1. import assertString from './util/assertString';
  2. var localeReg = /^[A-Za-z]{2,4}([_-]([A-Za-z]{4}|[\d]{3}))?([_-]([A-Za-z]{2}|[\d]{3}))?$/;
  3. export default function isLocale(str) {
  4. assertString(str);
  5. if (str === 'en_US_POSIX' || str === 'ca_ES_VALENCIA') {
  6. return true;
  7. }
  8. return localeReg.test(str);
  9. }