...
1
2
3
4
5
6
7
8
9
10 package main
11
12 import (
13 "flag"
14 "fmt"
15 "log"
16
17 "golang.org/x/text/internal/gen"
18 "golang.org/x/text/unicode/cldr"
19 )
20
21 var (
22 test = flag.Bool("test",
23 false,
24 "test existing tables; can be used to compare web data with package data.")
25 outputFile = flag.String("output",
26 "tables.go",
27 "output file for generated tables")
28 )
29
30 func main() {
31 gen.Init()
32
33 w := gen.NewCodeWriter()
34 defer w.WriteGoFile("tables.go", "compact")
35
36 fmt.Fprintln(w, `import "golang.org/x/text/internal/language"`)
37
38 b := newBuilder(w)
39 gen.WriteCLDRVersion(w)
40
41 b.writeCompactIndex()
42 }
43
44 type builder struct {
45 w *gen.CodeWriter
46 data *cldr.CLDR
47 supp *cldr.SupplementalData
48 }
49
50 func newBuilder(w *gen.CodeWriter) *builder {
51 r := gen.OpenCLDRCoreZip()
52 defer r.Close()
53 d := &cldr.Decoder{}
54 data, err := d.DecodeZip(r)
55 if err != nil {
56 log.Fatal(err)
57 }
58 b := builder{
59 w: w,
60 data: data,
61 supp: data.Supplemental(),
62 }
63 return &b
64 }
65
View as plain text