text: golang.org/x/text/internal/cldrtree Index | Files

package cldrtree

import "golang.org/x/text/internal/cldrtree"

Package cldrtree builds and generates a CLDR index file, including all inheritance.

Index

Package Files

cldrtree.go generate.go option.go tree.go type.go

type Builder Uses

type Builder struct {
    // contains filtered or unexported fields
}

A Builder allows storing CLDR data in compact form.

func New Uses

func New(tableName string) *Builder

New creates a new Builder.

func (*Builder) Gen Uses

func (b *Builder) Gen(w *gen.CodeWriter) error

Gen writes all the tables and types for the collected data.

func (*Builder) GenTestData Uses

func (b *Builder) GenTestData(w *gen.CodeWriter) error

GenTestData generates tables useful for testing data generated with Gen.

func (*Builder) Locale Uses

func (b *Builder) Locale(t language.Tag) *Index

Locale creates an index for the given locale.

type Element Uses

type Element interface {
    GetCommon() *cldr.Common
}

Element is a CLDR XML element.

type Index Uses

type Index struct {
    // contains filtered or unexported fields
}

An Index holds a map of either leaf values or other indices.

func (*Index) Index Uses

func (i *Index) Index(elem Element, opt ...Option) *Index

Index creates a subindex where the type and enum values are not shared with siblings by default. The name is derived from the elem. If elem is an alias reference, the alias will be resolved and linked. If elem is nil Index returns nil.

func (*Index) IndexFromAlt Uses

func (i *Index) IndexFromAlt(elem Element, opts ...Option) *Index

IndexFromAlt creates a subindex the value of tye alt attribute as key. It will also configure the Index to share the enumeration values with all sibling values. If elem is an alias, it will be resolved and linked.

func (*Index) IndexFromType Uses

func (i *Index) IndexFromType(elem Element, opts ...Option) *Index

IndexFromType creates a subindex the value of tye type attribute as key. It will also configure the Index to share the enumeration values with all sibling values. If elem is an alias, it will be resolved and linked.

func (*Index) IndexWithName Uses

func (i *Index) IndexWithName(name string, opt ...Option) *Index

IndexWithName is like Section but derives the name from the given name.

func (*Index) SetValue Uses

func (i *Index) SetValue(key string, value Element, opt ...Option)

SetValue sets the value, the data from a CLDR XML element, for the given key.

type Option Uses

type Option func(*options)

An Option configures an Index.

func Enum Uses

func Enum(name string, value ...string) Option

Enum defines a enumeration type. The resulting option may be passed for the construction of multiple Indexes, which they will share the same enum values. Calling Gen on a Builder will generate the Enum for the given name. The optional values fix the values for the given identifier to the argument position (starting at 0). Other values may still be added and will be assigned to subsequent values.

func EnumFunc Uses

func EnumFunc(name string, rename func(string) string, value ...string) Option

EnumFunc is like Enum but also takes a function that allows rewriting keys.

func SharedType Uses

func SharedType() Option

SharedType returns an option which causes all Indexes to which this option is passed to have the same type.

type Tree Uses

type Tree struct {
    Locales []uint32
    Indices []uint16
    Buckets []string
}

Tree holds a tree of CLDR data.

func (*Tree) Lookup Uses

func (t *Tree) Lookup(tag compact.ID, path ...uint16) string

Lookup looks up CLDR data for the given path. The lookup adheres to the alias and locale inheritance rules as defined in CLDR.

Each subsequent element in path indicates which subtree to select data from. The last element of the path must select a leaf node. All other elements of the path select a subindex.

func (*Tree) LookupFeature Uses

func (t *Tree) LookupFeature(tag compact.ID, path ...uint16) string

LookupFeature is like Lookup, but will first check whether a value of "other" as a fallback before traversing the inheritance chain.

Package cldrtree imports 13 packages (graph) and is imported by 4 packages. Updated 2018-09-13. Refresh now. Tools for package owners.