Documentation ¶
Overview ¶
Package cldrtree builds and generates a CLDR index file, including all inheritance.
Index ¶
- type Builder
- 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
- type Tree
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
A Builder allows storing CLDR data in compact form.
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.
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.
type Option ¶
type Option func(*options)
An Option configures an Index.
func Enum ¶
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 ¶
EnumFunc is like Enum but also takes a function that allows rewriting keys.
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.