iso

package
v0.0.0-...-17244d7 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2024 License: GPL-3.0 Imports: 7 Imported by: 0

README

ISO 标准配置解析库, 相关文件位于 /usr/share/xml/iso-codes/, 目前实现了 对 iso_3166.xml 的解析从而可以获取国家和地区的相关信息.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAllCountryCode

func GetAllCountryCode() (codeList []string, err error)

GetAllCountryCode return all country code.

func GetAllCountryNames

func GetAllCountryNames() (nameList []string, err error)

GetAllCountryNames return all country names.

func GetCountryCodeForLanguage

func GetCountryCodeForLanguage(language string) (code string, err error)

GetCountryCodeForLanguage return country code for a language variable, e.g. "CN" will be return if passing "zh_CN.UTF-8".

func GetCountryNameForCode

func GetCountryNameForCode(code string) (name string, err error)

GetCountryNameForCode return country name that corresponding to the country code.

func GetLocaleCountryCode

func GetLocaleCountryCode() (code string, err error)

GetLocaleCountryCode return locale country code by analysis environment variable "LANGUAGE".

func GetLocaleCountryName

func GetLocaleCountryName() (name string, err error)

GetLocaleCountryName return locale country name by analysis environment variable "LANGUAGE".

Types

type Country

type Country struct {
	Alpha2Code   string `xml:"alpha_2_code,attr"`
	Alpha3Code   string `xml:"alpha_3_code,attr"`
	NumericCode  string `xml:"numeric_code,attr"`
	CommonName   string `xml:"common_name,attr"`
	Name         string `xml:"name,attr"`
	OfficialName string `xml:"official_name,attr"`
}

type CountryDatabase

type CountryDatabase struct {
	Countries []Country `xml:"iso_3166_entry"`
}

map dtd of iso_3166.xml to go structures

func GetCountryDatabase

func GetCountryDatabase() (*CountryDatabase, error)

GetCountryDatabase return country database that marshaled from ISO 3166 xml file.

Jump to

Keyboard shortcuts

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