canonicalizedLocale function

String canonicalizedLocale(
  1. String? aLocale
)

Implementation

String canonicalizedLocale(String? aLocale) {
  if (aLocale == null) {
    return Intl.getCurrentLocale();
  }
  if (aLocale == 'C') {
    return 'en_ISO';
  }
  if (aLocale.length < 5) {
    return aLocale;
  }
  if (aLocale[2] != '-' && (aLocale[2] != '_')) {
    return aLocale;
  }
  var region = aLocale.substring(3);
// If it's longer than three it's something odd, so don't touch it.
  if (region.length <= 3) {
    region = region.toUpperCase();
  }

  return '${aLocale[0]}${aLocale[1]}_$region';
}