// Copyright 2018 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// Package compact defines a compact representation of language tags. // // Common language tags (at least all for which locale information is defined // in CLDR) are assigned a unique index. Each Tag is associated with such an // ID for selecting language-related resources (such as translations) as well // as one for selecting regional defaults (currency, number formatting, etc.) // // It may want to export this functionality at some point, but at this point // this is only available for use within x/text.
package compact // import "golang.org/x/text/internal/language/compact" import ( ) // ID is an integer identifying a single tag. type ID uint16 func getCoreIndex( language.Tag) ( ID, bool) { , := language.GetCompactCore() if ! { return 0, false } := sort.Search(len(coreTags), func( int) bool { return <= coreTags[] }) if == len(coreTags) || coreTags[] != { return 0, false } return ID(), true } // Parent returns the ID of the parent or the root ID if id is already the root. func ( ID) () ID { return parents[] } // Tag converts id to an internal language Tag. func ( ID) () language.Tag { if int() >= len(coreTags) { return specialTags[int()-len(coreTags)] } return coreTags[].Tag() } var specialTags []language.Tag func init() { := strings.Split(specialTagsStr, " ") specialTags = make([]language.Tag, len()) for , := range { specialTags[] = language.MustParse() } }