func fillLocaleData()

in generator.go [188:260]


func fillLocaleData(tag string, gregorianCalendar *Calendar, locale *cldrLocaleData) error {
	var err error
	if gregorianCalendar.Months != nil && gregorianCalendar.Months.MonthContext != nil {
		for _, monthContext := range gregorianCalendar.Months.MonthContext {
			if monthContext.Type != "format" {
				continue
			}

			for _, monthWidth := range monthContext.MonthWidth {
				if monthWidth.Type == "abbreviated" {
					locale.shortMonthNames, err = lookupMonthValue(locale.shortMonthNames, shortMonthNamesStd, monthWidth.Month)
					if err != nil {
						return fmt.Errorf("failed to read %s short month names %w", tag, err)
					}
				} else if monthWidth.Type == "wide" {
					locale.longMonthNames, err = lookupMonthValue(locale.longMonthNames, longMonthNamesStd, monthWidth.Month)
					if err != nil {
						return fmt.Errorf("failed to read %s long month names %w", tag, err)
					}
				}
			}
		}
	}

	if gregorianCalendar.Days != nil && gregorianCalendar.Days.DayContext != nil {
		for _, dayContext := range gregorianCalendar.Days.DayContext {
			if dayContext.Type != "format" {
				continue
			}

			for _, dayWidth := range dayContext.DayWidth {
				if dayWidth.Type == "abbreviated" {
					locale.shortDayNames = lookupDayValue(locale.shortDayNames, shortDayNamesStdMap, dayWidth.Day)
				} else if dayWidth.Type == "wide" {
					locale.longDayNames = lookupDayValue(locale.longDayNames, longDayNamesStdMap, dayWidth.Day)
				}
			}
		}
	}

	if gregorianCalendar.DayPeriods != nil && gregorianCalendar.DayPeriods.DayPeriodContext != nil {
		for _, periodContext := range gregorianCalendar.DayPeriods.DayPeriodContext {
			if periodContext.Type != "format" {
				continue
			}

			periods := map[string]string{}
			for _, periodWidth := range periodContext.DayPeriodWidth {
				if periodWidth.Type != "abbreviated" && periodWidth.Type != "narrow" {
					continue
				}

				for _, period := range periodWidth.DayPeriod {
					if p, ok := dayPeriodsStdMap[period.Type]; ok {
						// preference for non-variant periods
						if _, ok = periods[p]; ok && period.Alt == "variant" {
							continue
						}

						periods[p] = strings.ReplaceAll(period.CharData, "\u202F", "")
					}
				}

				if len(periods) == 2 {
					locale.dayPeriods = periods
					break
				}
			}
		}
	}

	return nil
}