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 FromRequest(req *http.Request) []language.Tag
- func LanguageStrings() []string
- func Make(lang string) language.Tag
- func Parse(tag string) (language.Tag, error)
- func ParseAcceptLanguage(acceptLanguage string) []language.Tag
- func PreferredLocale(acceptLanguage string) string
- func WithTags(ctx context.Context, tags ...Tag) context.Context
- type LocaleCode
- type Tag
- func Country2Language(lang Tag) Tag
- func CountryLanguage(lang Tag) Tag
- func FromTag(ctx context.Context) Tag
- func FromTags(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 FromRequest ΒΆ
FromRequest retrieves the Tag information from the HTTP request. req: The HTTP request from which to retrieve the Tag information. Returns a slice of Tag parsed from the "Accept-Language" header of the request.
func LanguageStrings ΒΆ
func LanguageStrings() []string
LanguageStrings returns a list of language strings for all languages in the Languages slice.
func ParseAcceptLanguage ΒΆ
ParseAcceptLanguage parses the "Accept-Language" header to obtain a slice of language.Tag. acceptLanguage: The value of the "Accept-Language" header. Returns a slice of language.Tag, or a slice containing only the default locale if parsing fails or the result is empty.
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 ΒΆ
func Country2Language ΒΆ
Country2Language converts a country tag to a language tag.
func CountryLanguage ΒΆ
CountryLanguage converts a country tag to a language tag with region.
func FromTag ΒΆ
FromTag retrieves the first Tag from the context. ctx: The context from which to retrieve the Tag information. Returns the first Tag, or the default locale if no Tag information is found or the slice is empty.
func FromTags ΒΆ
FromTags retrieves the Tag information from the context. ctx: The context from which to retrieve the Tag information. Returns a slice of Tag, or a slice containing only the default locale if no Tag information is found.
func Language2Country ΒΆ
Language2Country converts a language tag to a country tag.
func String2Country ΒΆ
String2Country converts a locale string to a country tag.
func String2Language ΒΆ
String2Language converts a locale string to a language tag.
func Unknown2Country ΒΆ
Unknown2Country converts an unknown language tag to a country tag.
func Unknown2Language ΒΆ
Unknown2Language converts an unknown language tag to a language tag.
Directories
ΒΆ
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
make
command
Package main implements the I18n data generation command.
|
Package main implements the I18n data generation command. |
|
Package tz implements the functions, types, and interfaces for the module.
|
Package tz implements the functions, types, and interfaces for the module. |