gg_country

package
v0.3.11 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2024 License: BSD-3-Clause Imports: 8 Imported by: 0

README

Country

Helper library for localization.

func TestCountry(t *testing.T) {
	code := "it"

	fmt.Println("Lang: ", code, gg.Country.Lang(code))
	fmt.Println("LangName: ", code, gg.Country.LangName(code))
	fmt.Println("CountryName: ", code, gg.Country.CountryName(code))
	fmt.Println("CurrencySymbol: ", code, gg.Country.CurrencySymbol(code))
	fmt.Println("CurrencyName: ", code, gg.Country.CurrencyName(code))
	fmt.Println("FormatDate: ", code, gg.Country.FormatDate(code, time.Now()))
	fmt.Println("FormatTime: ", code, gg.Country.FormatTimeHM(code, time.Now()))
	fmt.Println("FormatCurrency: ", code, gg.Country.FormatCurrency(code, 125.56888))

	code = "en"

	fmt.Println("Lang: ", code, gg.Country.Lang(code))
	fmt.Println("LangName: ", code, gg.Country.LangName(code))
	fmt.Println("CountryName: ", code, gg.Country.CountryName(code))
	fmt.Println("CurrencySymbol: ", code, gg.Country.CurrencySymbol(code))
	fmt.Println("CurrencyName: ", code, gg.Country.CurrencyName(code))
	fmt.Println("FormatDate: ", code, gg.Country.FormatDate(code, time.Now()))
	fmt.Println("FormatTime: ", code, gg.Country.FormatTimeHM(code, time.Now()))
	fmt.Println("FormatCurrency: ", code, gg.Country.FormatCurrency(code, 125.56888))

}

// OUTPUT:
=== RUN   TestCountry
Lang:  it it
LangName:  it Italiano
CountryName:  it Italia
CurrencySymbol:  it €
CurrencyName:  it EUR
FormatDate:  it Thursday, 28 November 2024
FormatTime:  it 09:24
FormatCurrency:  it €125,57
Lang:  en en
LangName:  en English
CountryName:  en USA
CurrencySymbol:  en $
CurrencyName:  en USD
FormatDate:  en Thursday, 28 November 2024
FormatTime:  en 09:24
FormatCurrency:  en $125.57
--- 

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CountryHelper

type CountryHelper struct {
	DefLang string
}
var Country *CountryHelper

func (*CountryHelper) CountryCode added in v0.2.110

func (instance *CountryHelper) CountryCode(langTag string) string

func (*CountryHelper) CountryName

func (instance *CountryHelper) CountryName(langTag string) string

func (*CountryHelper) CountryNameOf added in v0.2.110

func (instance *CountryHelper) CountryNameOf(langTag, outTag string) string

func (*CountryHelper) CurrencyName

func (instance *CountryHelper) CurrencyName(langTag string) string

func (*CountryHelper) CurrencySymbol

func (instance *CountryHelper) CurrencySymbol(langTag string) string

func (*CountryHelper) FormatCurrency

func (instance *CountryHelper) FormatCurrency(langTag string, value float64) string

func (*CountryHelper) FormatDate

func (instance *CountryHelper) FormatDate(langTag string, date time.Time) string

func (*CountryHelper) FormatTime

func (instance *CountryHelper) FormatTime(langTag string, date time.Time) string

func (*CountryHelper) FormatTimeHM

func (instance *CountryHelper) FormatTimeHM(langTag string, date time.Time) string

func (*CountryHelper) Lang

func (instance *CountryHelper) Lang(code string) string

Lang extracts the ISO 639-1 language code (e.g., "en", "it") from the provided language or locale code string.

func (*CountryHelper) LangName

func (instance *CountryHelper) LangName(lang string) string

LangName return ISO language name (i.e. "Italian") from a lang code like "it"

Jump to

Keyboard shortcuts

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