package cldrtree
import "golang.org/x/text/internal/cldrtree"
Package cldrtree builds and generates a CLDR index file, including all inheritance.
Index ¶
- type Builder
- func New(tableName string) *Builder
- func (b *Builder) Gen(w *gen.CodeWriter) error
- func (b *Builder) GenTestData(w *gen.CodeWriter) error
- func (b *Builder) Locale(t language.Tag) *Index
- type Element
- type Index
- func (i *Index) Index(elem Element, opt ...Option) *Index
- func (i *Index) IndexFromAlt(elem Element, opts ...Option) *Index
- func (i *Index) IndexFromType(elem Element, opts ...Option) *Index
- func (i *Index) IndexWithName(name string, opt ...Option) *Index
- func (i *Index) SetValue(key string, value Element, opt ...Option)
- type Option
- func Enum(name string, value ...string) Option
- func EnumFunc(name string, rename func(string) string, value ...string) Option
- func SharedType() Option
- type Tree
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
A Builder allows storing CLDR data in compact form.
func New ¶
New creates a new Builder.
func (*Builder) Gen ¶
func (b *Builder) Gen(w *gen.CodeWriter) error
Gen writes all the tables and types for the collected data.
func (*Builder) GenTestData ¶
func (b *Builder) GenTestData(w *gen.CodeWriter) error
GenTestData generates tables useful for testing data generated with Gen.
func (*Builder) Locale ¶
Locale creates an index for the given locale.
type Element ¶
Element is a CLDR XML element.
type Index ¶
type Index struct {
// contains filtered or unexported fields
}
An Index holds a map of either leaf values or other indices.
func (*Index) 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 ¶
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 ¶
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 ¶
IndexWithName is like Section but derives the name from the given name.
func (*Index) SetValue ¶
SetValue sets the value, the data from a CLDR XML element, for the given key.
type Option ¶
type Option func(*options)
An Option configures an Index.
func Enum ¶
Enum defines an 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 ¶
EnumFunc is like Enum but also takes a function that allows rewriting keys.
func SharedType ¶
func SharedType() Option
SharedType returns an option which causes all Indexes to which this option is passed to have the same type.
type Tree ¶
Tree holds a tree of CLDR data.
func (*Tree) Lookup ¶
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 ¶
LookupFeature is like Lookup, but will first check whether a value of "other" as a fallback before traversing the inheritance chain.
Source Files ¶
cldrtree.go generate.go option.go tree.go type.go
- Version
- v0.22.0 (latest)
- Published
- Feb 4, 2025
- Platform
- linux/amd64
- Imports
- 13 packages
- Last checked
- 1 day ago –
Tools for package owners.