i18n

package module
v0.0.27 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 6, 2025 License: MIT Imports: 7 Imported by: 0

README

I18n

1. Get tzdata from https://data.iana.org

1.1 Download tzdata from https://data.iana.org
mkdir tzdb
cd tzdb
wget https://www.iana.org/time-zones/repository/tzcode-latest.tar.gz
wget https://www.iana.org/time-zones/repository/tzdata-latest.tar.gz
gzip -dc tzcode-latest.tar.gz | tar -xf -
gzip -dc tzdata-latest.tar.gz | tar -xf -
1.2 Download tzdata from https://timezonedb.com
wget https://timezonedb.com/files/TimeZoneDB.csv.zip -O TimeZoneDB.csv.zip
zip -d TimeZoneDB.csv.zip
1.3 Download ldmlSupplemental.dtd from https://github.com/unicode-org/cldr/blob/main/common/dtd/ldmlSupplemental.dtd
1.4 Download windowsZones.xml from https://github.com/unicode-org/cldr/blob/main/common/supplemental/windowsZones.xml

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

Constants

This section is empty.

Variables

View Source
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 Compare

func Compare(lt, rt Tag) int

Compare compares two language tags and returns 1 if they match, 0 otherwise.

func CountryStrings

func CountryStrings() []string

CountryStrings returns a list of country strings based on the supported languages.

func LanguageFromRequest

func LanguageFromRequest(req *http.Request) *http.Request

func LanguageStrings

func LanguageStrings() []string

LanguageStrings returns a list of language strings for all languages in the Languages slice.

func Make added in v0.0.25

func Make(lang string) language.Tag

func Parse added in v0.0.25

func Parse(tag string) (language.Tag, error)

func PreferredLocale

func PreferredLocale(tags []Tag, localeStrings ...string) string

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

func WithContext

func WithContext(ctx context.Context, tag Tag) context.Context

Types

type LocaleCode

type LocaleCode struct {
	Locale          string `json:"Locale"`
	LanguageCode    string `json:"Language code"`
	LCIDString      string `json:"LCID string"`
	LCIDDecimal     int    `json:"LCID Decimal"`
	LCIDHexadecimal int    `json:"LCID Hexadecimal"`
	Codepage        int    `json:"Codepage"`
}

type Tag added in v0.0.25

type Tag = language.Tag

func Country2Language added in v0.0.25

func Country2Language(lang Tag) Tag

Country2Language converts a country tag to a language tag.

func CountryLanguage

func CountryLanguage(lang Tag) Tag

CountryLanguage converts a country tag to a language tag with region.

func FromContext

func FromContext(ctx context.Context) Tag

func Language2Country

func Language2Country(lang Tag) Tag

Language2Country converts a language tag to a country tag.

func String2Country added in v0.0.25

func String2Country(localeString string) Tag

String2Country converts a locale string to a country tag.

func String2Language

func String2Language(localeString string) Tag

String2Language converts a locale string to a language tag.

func Unknown2Country added in v0.0.25

func Unknown2Country(lang Tag) Tag

Unknown2Country converts an unknown language tag to a country tag.

func Unknown2Language added in v0.0.25

func Unknown2Language(lang Tag) Tag

Unknown2Language converts an unknown language tag to a language tag.

Directories

Path Synopsis
Package tz implements the functions, types, and interfaces for the module.
Package tz implements the functions, types, and interfaces for the module.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL