demos/src/LocaleSelector.js
function localeSupported(locale) {
  const language = locale.split('-')[0];
  if (language === 'en') {
    // Assume all flavors of English are supported.
    return true;
  }
  // Try formatting a Tuesday date, and if we get the English result "Tue",
  // the browser probably doesn't support the locale, and used the default
  // locale instead.
  const date = new Date('10 March 2015'); // A Tuesday
  const formatter = new Intl.DateTimeFormat(locale, { weekday: 'short' })
  const result = formatter.format(date);
  return result !== 'Tue';
}
function localeSupported(locale) {
  const language = locale.split('-')[0];
  if (language === 'en') {
    // Assume all flavors of English are supported.
    return true;
  }
  // Try formatting a Tuesday date, and if we get the English result "Tue",
  // the browser probably doesn't support the locale, and used the default
  // locale instead.
  const date = new Date('10 March 2015'); // A Tuesday
  const formatter = new Intl.DateTimeFormat(locale, { weekday: 'short' })
  const result = formatter.format(date);
  return result !== 'Tue';
}
function localeSupported ( locale ) { const language = locale . split ( '-' ) [ 0 ] ; if ( language === 'en' ) { // Assume all flavors of English are supported. return true ; } // Try formatting a Tuesday date, and if we get the English result "Tue", // the browser probably doesn't support the locale, and used the default // locale instead. const date = new Date ( '10 March 2015' ) ; // A Tuesday const formatter = new Intl . DateTimeFormat ( locale , { weekday : 'short' } ) const result = formatter . format ( date ) ; return result !== 'Tue' ; }
Heuristic that returns true if the given locale is supported.
Heuristic that returns true if the given locale is supported .