func formatForLang(t language.Tag, index []byte) *Format { for ; ; t = t.Parent() { if x, ok := language.CompactIndex(t); ok { return &formats[index[x]] } } }
// InfoFromTag returns a Info for the given language tag. func InfoFromTag(t language.Tag) Info { for { if index, ok := language.CompactIndex(t); ok { return InfoFromLangID(index, t.TypeForKey("nu")) } t = t.Parent() } }
func (c *Catalog) get(tag language.Tag, key string) (msg string, ok bool) { c.mutex.Lock() defer c.mutex.Unlock() for ; ; tag = tag.Parent() { if msgs, ok := c.index[tag]; ok { if statement, ok := msgs[key]; ok { // TODO: use type switches when we implement selecting. msg := string(statement.(format.String)) return msg, true } } if tag == language.Und { break } } return "", false }