Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllTags ¶
AllTags returns the built-in language tags from the golang.org/x/text/language package.
func Find ¶
Find returns the base language for the given region (country).
If `tags` are provided, only the provided tags are considered. Otherwise all built-in languages are considered (see AllTags). When a region matches multiple of the provided language tags, the last matched tag is returned.
Example:
base, confidence := regionlang.Find("at") // Find language for Austria base.String() == "de" // German is the Austrian language conf == language.Exact
Find searches through the allowed tags (f.tags) and compares the regions of the tags with the provided region. If the region of a language tag matches with the provided region, the base language of the tag is returned. In cases where the provided region matches multiple language tags, the last match with the highest confidence is returned.
If Find fails to parse the region, language.Make(region).Base() is returned.
Types ¶
type Finder ¶
type Finder struct {
// contains filtered or unexported fields
}
Finder finds base languages for regions (countries). Use NewFinder to create a Finder.
func (*Finder) Find ¶
Find returns the base language for the given region (country).
Example:
base, confidence := f.Find("at") // Find language for Austria base.String() == "de" // German is the Austrian language conf == language.Exact
Find searches through the allowed tags (f.tags) and compares the regions of the tags with the provided region. If the region of a language tag matches with the provided region, the base language of the tag is returned. In cases where the provided region matches multiple language tags, the last match with the highest confidence is returned.
If Find fails to parse the region, language.Make(region).Base() is returned.