package compact
Import Path
golang.org/x/text/internal/language/compact (on go.dev)
Dependency Relation
imports 3 packages, and imported by one package
Involved Source Files
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.
language.go
parents.go
tables.go
tags.go
Package-Level Type Names (total 2)
ID is an integer identifying a single tag.
Parent returns the ID of the parent or the root ID if id is already the root.
Tag converts id to an internal language Tag.
func FromTag(t language.Tag) (id ID, exact bool)
func LanguageID(t Tag) (id ID, exact bool)
func RegionalID(t Tag) (id ID, exact bool)
func ID.Parent() ID
Tag represents a BCP 47 language tag. It is used to specify an instance of a
specific language or locale. All language tag values are guaranteed to be
well-formed.
IsCompact reports whether this tag is fully defined in terms of ID.
IsRoot returns true if t is equal to language "und".
LanguageTag returns t stripped of regional variant indicators.
At the moment this means it is stripped of a regional and variant subtag "rg"
and "va" in the "u" extension.
MayHaveExtensions reports whether a tag may have extensions. If it returns
false it is guaranteed the tag does not have them.
MayHaveVariants reports whether a tag may have variants. If it returns false
it is guaranteed the tag does not have variants.
Parent returns the CLDR parent of t. In CLDR, missing fields in data for a
specific language are substituted with fields from the parent language.
The parent for a language may change for newer versions of CLDR.
RegionalTag returns the regional variant of the tag.
At the moment this means that the region is set from the regional subtag
"rg" in the "u" extension.
Tag returns an internal language Tag version of this tag.
func Make(t language.Tag) (tag Tag)
func Tag.LanguageTag() Tag
func Tag.Parent() Tag
func Tag.RegionalTag() Tag
func LanguageID(t Tag) (id ID, exact bool)
func RegionalID(t Tag) (id ID, exact bool)
var Afrikaans
var Albanian
var AmericanEnglish
var Amharic
var Arabic
var Armenian
var Azerbaijani
var Bengali
var BrazilianPortuguese
var BritishEnglish
var Bulgarian
var Burmese
var CanadianFrench
var Catalan
var Chinese
var Croatian
var Czech
var Danish
var Dutch
var English
var Estonian
var EuropeanPortuguese
var EuropeanSpanish
var Filipino
var Finnish
var French
var Georgian
var German
var Greek
var Gujarati
var Hebrew
var Hindi
var Hungarian
var Icelandic
var Indonesian
var Italian
var Japanese
var Kannada
var Kazakh
var Khmer
var Kirghiz
var Korean
var Lao
var LatinAmericanSpanish
var Latvian
var Lithuanian
var Macedonian
var Malay
var Malayalam
var Marathi
var ModernStandardArabic
var Mongolian
var Nepali
var Norwegian
var Persian
var Polish
var Portuguese
var Punjabi
var Romanian
var Russian
var Serbian
var SerbianLatin
var SimplifiedChinese
var Sinhala
var Slovak
var Slovenian
var Spanish
var Swahili
var Swedish
var Tamil
var Telugu
var Thai
var TraditionalChinese
var Turkish
var Ukrainian
var Und
var Urdu
var Uzbek
var Vietnamese
var Zulu
Package-Level Functions (total 4)
FromTag reports closest matching ID for an internal language Tag.
LanguageID returns an index, where 0 <= index < NumCompactTags, for tags
for which data exists in the text repository.The index will change over time
and should not be stored in persistent storage. If t does not match a compact
index, exact will be false and the compact index will be returned for the
first match after repeatedly taking the Parent of t.
Make a compact Tag from a fully specified internal language Tag.
RegionalID returns the ID for the regional variant of this tag. This index is
used to indicate region-specific overrides, such as default currency, default
calendar and week data, default time cycle, and default measurement system
and unit preferences.
For instance, the tag en-GB-u-rg-uszzzz specifies British English with US
settings for currency, number formatting, etc. The CompactIndex for this tag
will be that for en-GB, while the RegionalID will be the one corresponding to
en-US.
Package-Level Variables (total 80)
var AmericanEnglish Tag var Azerbaijani Tag var BritishEnglish Tag var CanadianFrench Tag var EuropeanSpanish Tag var Indonesian Tag var Lithuanian Tag var Macedonian Tag var Portuguese Tag var SerbianLatin Tag var SimplifiedChinese Tag var Vietnamese Tag
Package-Level Constants (total 2)
CLDRVersion is the CLDR version from which the tables in this package are derived.
NumCompactTags is the number of common tags. The maximum tag is
NumCompactTags-1.
![]() |
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. |