summaryrefslogtreecommitdiff
path: root/vendor/golang.org/x/text/internal/language/compact
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/golang.org/x/text/internal/language/compact')
-rw-r--r--vendor/golang.org/x/text/internal/language/compact/gen.go64
-rw-r--r--vendor/golang.org/x/text/internal/language/compact/gen_index.go113
-rw-r--r--vendor/golang.org/x/text/internal/language/compact/gen_parents.go54
3 files changed, 0 insertions, 231 deletions
diff --git a/vendor/golang.org/x/text/internal/language/compact/gen.go b/vendor/golang.org/x/text/internal/language/compact/gen.go
deleted file mode 100644
index 0c36a05..0000000
--- a/vendor/golang.org/x/text/internal/language/compact/gen.go
+++ /dev/null
@@ -1,64 +0,0 @@
-// Copyright 2013 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// +build ignore
-
-// Language tag table generator.
-// Data read from the web.
-
-package main
-
-import (
- "flag"
- "fmt"
- "log"
-
- "golang.org/x/text/internal/gen"
- "golang.org/x/text/unicode/cldr"
-)
-
-var (
- test = flag.Bool("test",
- false,
- "test existing tables; can be used to compare web data with package data.")
- outputFile = flag.String("output",
- "tables.go",
- "output file for generated tables")
-)
-
-func main() {
- gen.Init()
-
- w := gen.NewCodeWriter()
- defer w.WriteGoFile("tables.go", "compact")
-
- fmt.Fprintln(w, `import "golang.org/x/text/internal/language"`)
-
- b := newBuilder(w)
- gen.WriteCLDRVersion(w)
-
- b.writeCompactIndex()
-}
-
-type builder struct {
- w *gen.CodeWriter
- data *cldr.CLDR
- supp *cldr.SupplementalData
-}
-
-func newBuilder(w *gen.CodeWriter) *builder {
- r := gen.OpenCLDRCoreZip()
- defer r.Close()
- d := &cldr.Decoder{}
- data, err := d.DecodeZip(r)
- if err != nil {
- log.Fatal(err)
- }
- b := builder{
- w: w,
- data: data,
- supp: data.Supplemental(),
- }
- return &b
-}
diff --git a/vendor/golang.org/x/text/internal/language/compact/gen_index.go b/vendor/golang.org/x/text/internal/language/compact/gen_index.go
deleted file mode 100644
index 136cefa..0000000
--- a/vendor/golang.org/x/text/internal/language/compact/gen_index.go
+++ /dev/null
@@ -1,113 +0,0 @@
-// Copyright 2015 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// +build ignore
-
-package main
-
-// This file generates derivative tables based on the language package itself.
-
-import (
- "fmt"
- "log"
- "sort"
- "strings"
-
- "golang.org/x/text/internal/language"
-)
-
-// Compact indices:
-// Note -va-X variants only apply to localization variants.
-// BCP variants only ever apply to language.
-// The only ambiguity between tags is with regions.
-
-func (b *builder) writeCompactIndex() {
- // Collect all language tags for which we have any data in CLDR.
- m := map[language.Tag]bool{}
- for _, lang := range b.data.Locales() {
- // We include all locales unconditionally to be consistent with en_US.
- // We want en_US, even though it has no data associated with it.
-
- // TODO: put any of the languages for which no data exists at the end
- // of the index. This allows all components based on ICU to use that
- // as the cutoff point.
- // if x := data.RawLDML(lang); false ||
- // x.LocaleDisplayNames != nil ||
- // x.Characters != nil ||
- // x.Delimiters != nil ||
- // x.Measurement != nil ||
- // x.Dates != nil ||
- // x.Numbers != nil ||
- // x.Units != nil ||
- // x.ListPatterns != nil ||
- // x.Collations != nil ||
- // x.Segmentations != nil ||
- // x.Rbnf != nil ||
- // x.Annotations != nil ||
- // x.Metadata != nil {
-
- // TODO: support POSIX natively, albeit non-standard.
- tag := language.Make(strings.Replace(lang, "_POSIX", "-u-va-posix", 1))
- m[tag] = true
- // }
- }
-
- // TODO: plural rules are also defined for the deprecated tags:
- // iw mo sh tl
- // Consider removing these as compact tags.
-
- // Include locales for plural rules, which uses a different structure.
- for _, plurals := range b.supp.Plurals {
- for _, rules := range plurals.PluralRules {
- for _, lang := range strings.Split(rules.Locales, " ") {
- m[language.Make(lang)] = true
- }
- }
- }
-
- var coreTags []language.CompactCoreInfo
- var special []string
-
- for t := range m {
- if x := t.Extensions(); len(x) != 0 && fmt.Sprint(x) != "[u-va-posix]" {
- log.Fatalf("Unexpected extension %v in %v", x, t)
- }
- if len(t.Variants()) == 0 && len(t.Extensions()) == 0 {
- cci, ok := language.GetCompactCore(t)
- if !ok {
- log.Fatalf("Locale for non-basic language %q", t)
- }
- coreTags = append(coreTags, cci)
- } else {
- special = append(special, t.String())
- }
- }
-
- w := b.w
-
- sort.Slice(coreTags, func(i, j int) bool { return coreTags[i] < coreTags[j] })
- sort.Strings(special)
-
- w.WriteComment(`
- NumCompactTags is the number of common tags. The maximum tag is
- NumCompactTags-1.`)
- w.WriteConst("NumCompactTags", len(m))
-
- fmt.Fprintln(w, "const (")
- for i, t := range coreTags {
- fmt.Fprintf(w, "%s ID = %d\n", ident(t.Tag().String()), i)
- }
- for i, t := range special {
- fmt.Fprintf(w, "%s ID = %d\n", ident(t), i+len(coreTags))
- }
- fmt.Fprintln(w, ")")
-
- w.WriteVar("coreTags", coreTags)
-
- w.WriteConst("specialTagsStr", strings.Join(special, " "))
-}
-
-func ident(s string) string {
- return strings.Replace(s, "-", "", -1) + "Index"
-}
diff --git a/vendor/golang.org/x/text/internal/language/compact/gen_parents.go b/vendor/golang.org/x/text/internal/language/compact/gen_parents.go
deleted file mode 100644
index 9543d58..0000000
--- a/vendor/golang.org/x/text/internal/language/compact/gen_parents.go
+++ /dev/null
@@ -1,54 +0,0 @@
-// Copyright 2018 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// +build ignore
-
-package main
-
-import (
- "log"
-
- "golang.org/x/text/internal/gen"
- "golang.org/x/text/internal/language"
- "golang.org/x/text/internal/language/compact"
- "golang.org/x/text/unicode/cldr"
-)
-
-func main() {
- r := gen.OpenCLDRCoreZip()
- defer r.Close()
-
- d := &cldr.Decoder{}
- data, err := d.DecodeZip(r)
- if err != nil {
- log.Fatalf("DecodeZip: %v", err)
- }
-
- w := gen.NewCodeWriter()
- defer w.WriteGoFile("parents.go", "compact")
-
- // Create parents table.
- type ID uint16
- parents := make([]ID, compact.NumCompactTags)
- for _, loc := range data.Locales() {
- tag := language.MustParse(loc)
- index, ok := compact.FromTag(tag)
- if !ok {
- continue
- }
- parentIndex := compact.ID(0) // und
- for p := tag.Parent(); p != language.Und; p = p.Parent() {
- if x, ok := compact.FromTag(p); ok {
- parentIndex = x
- break
- }
- }
- parents[index] = ID(parentIndex)
- }
-
- w.WriteComment(`
- parents maps a compact index of a tag to the compact index of the parent of
- this tag.`)
- w.WriteVar("parents", parents)
-}