Source File
compact.go
Belonging Package
golang.org/x/text/internal/language/compact
// 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 uint16func 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.Tagfunc init() {:= strings.Split(specialTagsStr, " ")specialTags = make([]language.Tag, len())for , := range {specialTags[] = language.MustParse()}}
![]() |
The pages are generated with Golds v0.6.7. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |