cldrtree

package
v0.0.0-...-73df0bb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 30, 2018 License: Apache-2.0, BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Overview

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

Index

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 New

func New(tableName string) *Builder

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

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

Locale creates an index for the given locale.

type Element

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

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

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

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

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

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

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

func (*Index) SetValue

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

type Option func(*options)

An Option configures an Index.

func Enum

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

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

func SharedType() Option

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

type Tree

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

Tree holds a tree of CLDR data.

func (*Tree) Lookup

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

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL