// parseCollation parses XML files in the collation directory of the CLDR core.zip file. func parseCollation(b *build.Builder) { d := &cldr.Decoder{} d.SetDirFilter("collation") data := decodeCLDR(d) for _, loc := range data.Locales() { x, err := data.LDML(loc) failOnError(err) if skipLang(x.Identity.Language.Type) { continue } cs := x.Collations.Collation sl := cldr.MakeSlice(&cs) if !types.all { sl.SelectAnyOf("type", append(types.s, x.Collations.Default())...) } sl.SelectOnePerGroup("alt", altInclude()) for _, c := range cs { m := make(map[language.Part]string) m[language.TagPart] = loc if c.Type != x.Collations.Default() { m[language.Extension('u')] = "co-" + c.Type } id, err := language.Compose(m) failOnError(err) t := b.Tailoring(id) c.Process(processor{t}) } } }
// parseCollation parses XML files in the collation directory of the CLDR core.zip file. func parseCollation(b *build.Builder) { d := &cldr.Decoder{} d.SetDirFilter("collation") data := decodeCLDR(d) for _, loc := range data.Locales() { x, err := data.LDML(loc) failOnError(err) if skipLang(x.Identity.Language.Type) { continue } cs := x.Collations.Collation sl := cldr.MakeSlice(&cs) if len(types.s) == 0 { sl.SelectAnyOf("type", x.Collations.Default()) } else if !types.all { sl.SelectAnyOf("type", types.s...) } sl.SelectOnePerGroup("alt", altInclude()) for _, c := range cs { id, err := language.Parse(loc) if err != nil { fmt.Fprintf(os.Stderr, "invalid locale: %q", err) continue } // Support both old- and new-style defaults. d := c.Type if x.Collations.DefaultCollation == nil { d = x.Collations.Default() } else { d = x.Collations.DefaultCollation.Data() } // We assume tables are being built either for search or collation, // but not both. For search the default is always "search". if d != c.Type && c.Type != "search" { typ := c.Type if len(c.Type) > 8 { typ = typeMap[c.Type] } id, err = id.SetTypeForKey("co", typ) failOnError(err) } t := b.Tailoring(id) c.Process(processor{t}) } } }