示例#1
0
// Tailoring returns a Tailoring for the given locale.  One should
// have completed all calls to Add before calling Tailoring.
func (b *Builder) Tailoring(loc language.Tag) *Tailoring {
	t := &Tailoring{
		id:      loc.String(),
		builder: b,
		index:   b.root.clone(),
	}
	t.index.id = t.id
	b.locale = append(b.locale, t)
	return t
}
示例#2
0
// New returns a new Collator initialized for the given locale.
func New(t language.Tag) *Collator {
	// TODO: handle locale selection according to spec.
	var tab tableIndex
	loc := t.String()
	if loc != "" {
		if idx, ok := locales[loc]; ok {
			tab = idx
		} else {
			tab = locales["und"]
		}
	}
	return NewFromTable(colltab.Init(tab))
}
示例#3
0
// identifier creates an identifier from the given tag.
func identifier(t language.Tag) string {
	return strings.Replace(t.String(), "-", "", -1)
}