Exemplo n.º 1
0
func formatForLang(t language.Tag, index []byte) *Format {
	for ; ; t = t.Parent() {
		if x, ok := language.CompactIndex(t); ok {
			return &formats[index[x]]
		}
	}
}
Exemplo n.º 2
0
// 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()
	}
}
Exemplo n.º 3
0
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
}