Documentation ¶
Overview ¶
Package i18n implements the functions, types, and interfaces for the module.
Package i18n implements the functions, types, and interfaces for the module.
Package i18n implements the functions, types, and interfaces for the module.
Package i18n implements the functions, types, and interfaces for the module.
Package i18n implements the functions, types, and interfaces for the module.
Package i18n implements the functions, types, and interfaces for the module.
Package i18n implements the functions, types, and interfaces for the module.
Index ¶
- Variables
- func Compare(lt, rt Tag) int
- func CountryStrings() []string
- func LanguageFromRequest(req *http.Request) *http.Request
- func LanguageStrings() []string
- func Make(lang string) language.Tag
- func Parse(tag string) (language.Tag, error)
- func PreferredLocale(tags []Tag, localeStrings ...string) string
- func WithContext(ctx context.Context, tag Tag) context.Context
- type LocaleCode
- type Tag
- func Country2Language(lang Tag) Tag
- func CountryLanguage(lang Tag) Tag
- func FromContext(ctx context.Context) Tag
- func Language2Country(lang Tag) Tag
- func String2Country(localeString string) Tag
- func String2Language(localeString string) Tag
- func Unknown2Country(lang Tag) Tag
- func Unknown2Language(lang Tag) Tag
Constants ¶
This section is empty.
Variables ¶
var ( // Locales is the current system language settings Locales = locale.Languages() // DefaultLocale is the default system language settings DefaultLocale = Make(defaultLocaleString) Languages = []Tag{ language.Afrikaans, language.Amharic, language.Arabic, language.ModernStandardArabic, language.Azerbaijani, language.Bulgarian, language.Bengali, language.Catalan, language.Czech, language.Danish, language.German, language.Greek, language.English, language.AmericanEnglish, language.BritishEnglish, language.Spanish, language.EuropeanSpanish, language.LatinAmericanSpanish, language.Estonian, language.Persian, language.Finnish, language.Filipino, language.French, language.CanadianFrench, language.Gujarati, language.Hebrew, language.Hindi, language.Croatian, language.Hungarian, language.Armenian, language.Indonesian, language.Icelandic, language.Italian, language.Japanese, language.Georgian, language.Kazakh, language.Khmer, language.Kannada, language.Korean, language.Kirghiz, language.Lao, language.Lithuanian, language.Latvian, language.Macedonian, language.Malayalam, language.Mongolian, language.Marathi, language.Malay, language.Burmese, language.Nepali, language.Dutch, language.Norwegian, language.Punjabi, language.Polish, language.Portuguese, language.BrazilianPortuguese, language.EuropeanPortuguese, language.Romanian, language.Russian, language.Sinhala, language.Slovak, language.Slovenian, language.Albanian, language.Serbian, language.SerbianLatin, language.Swedish, language.Swahili, language.Tamil, language.Telugu, language.Thai, language.Turkish, language.Ukrainian, language.Urdu, language.Uzbek, language.Vietnamese, language.Chinese, language.SimplifiedChinese, language.TraditionalChinese, language.Zulu, } )
Functions ¶
func CountryStrings ¶
func CountryStrings() []string
CountryStrings returns a list of country strings based on the supported languages.
func LanguageStrings ¶
func LanguageStrings() []string
LanguageStrings returns a list of language strings for all languages in the Languages slice.
func PreferredLocale ¶
PreferredLocale gets the current system language settings multi-language are supported, the first match is returned if no match is found, the default system language settings is returned
Types ¶
type LocaleCode ¶
type Tag ¶ added in v0.0.25
func Country2Language ¶ added in v0.0.25
Country2Language converts a country tag to a language tag.
func CountryLanguage ¶
CountryLanguage converts a country tag to a language tag with region.
func FromContext ¶
func Language2Country ¶
Language2Country converts a language tag to a country tag.
func String2Country ¶ added in v0.0.25
String2Country converts a locale string to a country tag.
func String2Language ¶
String2Language converts a locale string to a language tag.
func Unknown2Country ¶ added in v0.0.25
Unknown2Country converts an unknown language tag to a country tag.
func Unknown2Language ¶ added in v0.0.25
Unknown2Language converts an unknown language tag to a language tag.