Source File
language.go
Belonging Package
golang.org/x/text/language
package language
import (
)
Default = Deprecated | Legacy
canonLang = DeprecatedBase | Legacy | Macro
)
func ( CanonType, language.Tag) (language.Tag, bool) {
if == Raw {
return , false
}
:= false
if &SuppressScript != 0 {
if .LangID.SuppressScript() == .ScriptID {
.ScriptID = 0
= true
}
}
if &canonLang != 0 {
for {
if , := .LangID.Canonicalize(); != .LangID {
switch {
case language.Legacy:
if &Legacy != 0 {
if .LangID == _sh && .ScriptID == 0 {
.ScriptID = _Latn
}
.LangID =
= true
}
case language.Macro:
if , := canonicalize(, .tag()); {
.RemakeString()
return makeTag(), nil
}
return , nil
}
type Confidence int
const (
No Confidence = iota // full confidence that there was no match
Low // most likely value picked out of a set of alternatives
High // value is generally assumed to be the correct match
Exact // exact match or explicitly specified value
)
var confName = []string{"No", "Low", "High", "Exact"}
func ( Confidence) () string {
return confName[]
}
func ( Tag) () ( []byte, error) {
return .tag().MarshalText()
}
func ( Tag) () (Region, Confidence) {
if := .region(); != 0 {
return Region{}, Exact
}
:= .tag()
if , := .Maximize(); == nil {
return Region{.RegionID}, Low // TODO: differentiate between high and low.
}
, _ = canonicalize(Deprecated|Macro, )
if , := .Maximize(); == nil {
return Region{.RegionID}, Low
}
return Region{_ZZ}, No // TODO: return world instead of undetermined?
}
func ( Tag) ( string) string {
if !compact.Tag().MayHaveExtensions() {
if != "rg" && != "va" {
return ""
}
}
return .tag().TypeForKey()
}
const NumCompactTags = compact.NumCompactTags
func ( Base) () bool {
return .langID.IsPrivateUse()
}
func ( Script) () bool {
return .scriptID.IsPrivateUse()
}
func ( Region) () bool {
return .regionID.IsPrivateUse()
}
func ( Region) () Region {
return Region{.regionID.Canonicalize()}
}
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin 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. |