示例#1
0
// Build builds the root Collator.
// TODO: return Weigher instead
func (b *Builder) Build() (colltab.Weigher, error) {
	t, err := b.build()
	if err != nil {
		return nil, err
	}
	table := colltab.Init(t)
	if table == nil {
		panic("generated table of incompatible type")
	}
	return table, nil
}
示例#2
0
// New returns a new Collator initialized for the given locale.
func New(loc string) *Collator {
	// TODO: handle locale selection according to spec.
	var t tableIndex
	if loc != "" {
		if idx, ok := locales[loc]; ok {
			t = idx
		} else {
			t = locales["root"]
		}
	}
	return NewFromTable(colltab.Init(t))
}