Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var NilCountry = Country("")
NilCountry represents our nil, or unknown country
var NilLanguage = Language("")
NilLanguage represents our nil, or unknown language
var NilLocale = Locale("")
Functions ¶
This section is empty.
Types ¶
type BCP47Matcher ¶
type BCP47Matcher struct {
// contains filtered or unexported fields
}
BCP47Matcher helps find best matching locale from a set of available locales
func NewBCP47Matcher ¶
func NewBCP47Matcher(codes ...string) *BCP47Matcher
NewBCP47Matcher creates a new BCP47 matcher from the set of available locales which must be valid BCP47 tags.
func (*BCP47Matcher) ForLocales ¶
func (m *BCP47Matcher) ForLocales(preferred ...Locale) string
type Country ¶
type Country string
Country is a ISO 3166-1 alpha-2 country code
func DeriveCountryFromTel ¶
DeriveCountryFromTel attempts to derive a country code (e.g. RW) from a phone number
func (Country) MarshalJSON ¶
func (*Country) UnmarshalJSON ¶
type Language ¶
type Language string
Language is holds a an ISO-639-3 language code.
func ParseLanguage ¶
ParseLanguage returns a new Language for the passed in language string, or an error if not found
func (Language) ISO639_1 ¶
ISO639_1 returns the ISO-639-1 2-letter code for this language if it has one
func (Language) MarshalJSON ¶
func (*Language) UnmarshalJSON ¶
type Locale ¶
type Locale string
Locale is the combination of a language and optional country, e.g. US English, Brazilian Portuguese, encoded as the language code followed by the country code, e.g. eng-US, por-BR. Every locale is valid BCP47 language tag, tho not every BCP47 language tag is a valid goflow locale because we only use ISO-639-3 3 letter codes to represent language.