1 // Copyright 2015 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
12 "golang.org/x/text/internal/gen"
13 "golang.org/x/text/language"
14 "golang.org/x/text/unicode/cldr"
18 r := gen.OpenCLDRCoreZip()
22 data, err := d.DecodeZip(r)
24 log.Fatalf("DecodeZip: %v", err)
27 w := gen.NewCodeWriter()
28 defer w.WriteGoFile("tables.go", "internal")
30 // Create parents table.
31 parents := make([]uint16, language.NumCompactTags)
32 for _, loc := range data.Locales() {
33 tag := language.MustParse(loc)
34 index, ok := language.CompactIndex(tag)
38 parentIndex := 0 // und
39 for p := tag.Parent(); p != language.Und; p = p.Parent() {
40 if x, ok := language.CompactIndex(p); ok {
45 parents[index] = uint16(parentIndex)
49 Parent maps a compact index of a tag to the compact index of the parent of
51 w.WriteVar("Parent", parents)