resolveWeekInfo function

WeekInfo resolveWeekInfo(
  1. String locale
)

Resolves the WeekInfo for a locale by its region (explicit, or inferred from CLDR likely-subtags for region-less locales), falling back to the world default.

Implementation

WeekInfo resolveWeekInfo(String locale) {
  var id = BaseLanguageId.parse(locale);
  var region = id.region;
  if (region == null) {
    var lang = id.lang ?? '';
    var langKey = id.script != null ? '$lang-${id.script}' : lang;
    region = likelyRegion[langKey] ?? likelyRegion[lang] ?? '001';
  }
  return weekDataByRegion[region] ?? weekDataByRegion['001']!;
}