l10n

package
v0.210.0 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2025 License: Apache-2.0 Imports: 5 Imported by: 14

Documentation

Overview

Package l10n provides localization models and data.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Code added in v0.20.0

type Code string

Code is used for short identifiers like country or state codes. They are limited to upper-case letters and numbers only, and should be validated against region specific data.

const (
	// Afghanistan
	AF Code = "AF"
	// Åland Islands
	AX Code = "AX"
	// Albania
	AL Code = "AL"
	// Algeria
	DZ Code = "DZ"
	// American Samoa
	AS Code = "AS"
	AD Code = "AD"
	// Angola
	AO Code = "AO"
	// Anguilla
	AI Code = "AI"
	// Antarctica
	AQ Code = "AQ"
	// Antigua and Barbuda
	AG Code = "AG"
	// Argentina
	AR Code = "AR"
	// Armenia
	AM Code = "AM"
	// Aruba
	AW Code = "AW"
	// Australia
	AU Code = "AU"
	// Austria
	AT Code = "AT"
	// Azerbaijan
	AZ Code = "AZ"
	// Bahamas
	BS Code = "BS"
	// Bahrain
	BH Code = "BH"
	// Bangladesh
	BD Code = "BD"
	// Barbados
	BB Code = "BB"
	// Belarus
	BY Code = "BY"
	// Belgium
	BE Code = "BE"
	// Belize
	BZ Code = "BZ"
	// Benin
	BJ Code = "BJ"
	// Bermuda
	BM Code = "BM"
	// Bhutan
	BT Code = "BT"
	// Bolivia, Plurinational State of
	BO Code = "BO"
	// Bonaire, Sint Eustatius and Saba
	BQ Code = "BQ"
	// Bosnia and Herzegovina
	BA Code = "BA"
	// Botswana
	BW Code = "BW"
	// Bouvet Island
	BV Code = "BV"
	// Brazil
	BR Code = "BR"
	// British Indian Ocean Territory
	IO Code = "IO"
	// Brunei Darussalam
	BN Code = "BN"
	// Bulgaria
	BG Code = "BG"
	// Burkina Faso
	BF Code = "BF"
	// Burundi
	BI Code = "BI"
	// Cabo Verde
	CV Code = "CV"
	// Cambodia
	KH Code = "KH"
	// Cameroon
	CM Code = "CM"
	// Canada
	CA Code = "CA"
	// Cayman Islands
	KY Code = "KY"
	// Central African Republic
	CF Code = "CF"
	// Chad
	TD Code = "TD"
	// Chile
	CL Code = "CL"
	// China
	CN Code = "CN"
	// Christmas Island
	CX Code = "CX"
	// Cocos (Keeling) Islands
	CC Code = "CC"
	// Colombia
	CO Code = "CO"
	// Comoros
	KM Code = "KM"
	// Congo
	CG Code = "CG"
	// Congo, Democratic Republic of the
	CD Code = "CD"
	// Cook Islands
	CK Code = "CK"
	// Costa Rica
	CR Code = "CR"
	// Côte d'Ivoire
	CI Code = "CI"
	// Croatia
	HR Code = "HR"
	// Cuba
	CU Code = "CU"
	// Curaçao
	CW Code = "CW"
	// Cyprus
	CY Code = "CY"
	// Czechia
	CZ Code = "CZ"
	// Denmark
	DK Code = "DK"
	// Djibouti
	DJ Code = "DJ"
	// Dominica
	DM Code = "DM"
	// Dominican Republic
	DO Code = "DO"
	// Ecuador
	EC Code = "EC"
	// Egypt
	EG Code = "EG"
	// El Salvador
	SV Code = "SV"
	// Equatorial Guinea
	GQ Code = "GQ"
	// Eritrea
	ER Code = "ER"
	// Estonia
	EE Code = "EE"
	// Eswatini
	SZ Code = "SZ"
	// Ethiopia
	ET Code = "ET"
	// Falkland Islands
	FK Code = "FK"
	// Faroe Islands
	FO Code = "FO"
	// Fiji
	FJ Code = "FJ"
	// Finland
	FI Code = "FI"
	// France
	FR Code = "FR"
	// French Guiana
	GF Code = "GF"
	// French Polynesia
	PF Code = "PF"
	// French Southern Territories
	TF Code = "TF"
	// Gabon
	GA Code = "GA"
	// Gambia
	GM Code = "GM"
	// Georgia
	GE Code = "GE"
	// Germany
	DE Code = "DE"
	// Ghana
	GH Code = "GH"
	// Gibraltar
	GI Code = "GI"
	// Greece
	GR Code = "GR"
	// Greenland
	GL Code = "GL"
	// Grenada
	GD Code = "GD"
	// Guadeloupe
	GP Code = "GP"
	// Guam
	GU Code = "GU"
	// Guatemala
	GT Code = "GT"
	// Guernsey
	GG Code = "GG"
	// Guinea
	GN Code = "GN"
	// Guinea-Bissau
	GW Code = "GW"
	// Guyana
	GY Code = "GY"
	// Haiti
	HT Code = "HT"
	// Heard Island and McDonald Islands
	HM Code = "HM"
	// Holy See (the)
	VA Code = "VA"
	// Honduras
	HN Code = "HN"
	// Hong Kong
	HK Code = "HK"
	// Hungary
	HU Code = "HU"
	// Iceland
	IS Code = "IS"
	// India
	IN Code = "IN"
	// Indonesia
	ID Code = "ID"
	// Iran, Islamic Republic of
	IR Code = "IR"
	// Iraq
	IQ Code = "IQ"
	// Ireland
	IE Code = "IE"
	// Isle of Man
	IM Code = "IM"
	// Israel
	IL Code = "IL"
	// Italy
	IT Code = "IT"
	// Jamaica
	JM Code = "JM"
	// Japan
	JP Code = "JP"
	// Jersey
	JE Code = "JE"
	// Jordan
	JO Code = "JO"
	// Kazakhstan
	KZ Code = "KZ"
	// Kenya
	KE Code = "KE"
	// Kiribati
	KI Code = "KI"
	// Korea, Democratic People's Republic of
	KP Code = "KP"
	// Korea, Republic of
	KR Code = "KR"
	// Kuwait
	KW Code = "KW"
	// Kyrgyzstan
	KG Code = "KG"
	// Lao People's Democratic Republic
	LA Code = "LA"
	// Latvia
	LV Code = "LV"
	// Lebanon
	LB Code = "LB"
	// Lesotho
	LS Code = "LS"
	// Liberia
	LR Code = "LR"
	// Libya
	LY Code = "LY"
	// Liechtenstein
	LI Code = "LI"
	// Lithuania
	LT Code = "LT"
	// Luxembourg
	LU Code = "LU"
	// Macao
	MO Code = "MO"
	// Madagascar
	MG Code = "MG"
	// Malawi
	MW Code = "MW"
	// Malaysia
	MY Code = "MY"
	// Maldives
	MV Code = "MV"
	// Mali
	ML Code = "ML"
	// Malta
	MT Code = "MT"
	// Marshall Islands
	MH Code = "MH"
	// Martinique
	MQ Code = "MQ"
	// Mauritania
	MR Code = "MR"
	// Mauritius
	MU Code = "MU"
	// Mayotte
	YT Code = "YT"
	// Mexico
	MX Code = "MX"
	// Micronesia, Federated States of
	FM Code = "FM"
	// Moldova, Republic of
	MD Code = "MD"
	// Monaco
	MC Code = "MC"
	// Mongolia
	MN Code = "MN"
	// Montenegro
	ME Code = "ME"
	// Montserrat
	MS Code = "MS"
	// Morocco
	MA Code = "MA"
	// Mozambique
	MZ Code = "MZ"
	// Myanmar
	MM Code = "MM"
	// Namibia
	NA Code = "NA"
	// Nauru
	NR Code = "NR"
	// Nepal
	NP Code = "NP"
	// Netherlands
	NL Code = "NL"
	// New Caledonia
	NC Code = "NC"
	// New Zealand
	NZ Code = "NZ"
	// Nicaragua
	NI Code = "NI"
	// Niger
	NE Code = "NE"
	// Nigeria
	NG Code = "NG"
	// Niue
	NU Code = "NU"
	// Norfolk Island
	NF Code = "NF"
	// North Macedonia
	MK Code = "MK"
	// Northern Mariana Islands
	MP Code = "MP"
	// Norway
	NO Code = "NO"
	// Oman
	OM Code = "OM"
	// Pakistan
	PK Code = "PK"
	// Palau
	PW Code = "PW"
	// Palestine, State of
	PS Code = "PS"
	// Panama
	PA Code = "PA"
	// Papua New Guinea
	PG Code = "PG"
	// Paraguay
	PY Code = "PY"
	// Peru
	PE Code = "PE"
	// Philippines
	PH Code = "PH"
	// Pitcairn
	PN Code = "PN"
	// Poland
	PL Code = "PL"
	// Portugal
	PT Code = "PT"
	// Puerto Rico
	PR Code = "PR"
	// Qatar
	QA Code = "QA"
	// Réunion
	RE Code = "RE"
	// Romania
	RO Code = "RO"
	// Russian Federation
	RU Code = "RU"
	// Rwanda
	RW Code = "RW"
	// Saint Barthélemy
	BL Code = "BL"
	// Saint Helena, Ascension and Tristan da Cunha
	SH Code = "SH"
	// Saint Kitts and Nevis
	KN Code = "KN"
	// Saint Lucia
	LC Code = "LC"
	// Saint Martin (French part)
	MF Code = "MF"
	// Saint Pierre and Miquelon
	PM Code = "PM"
	// Saint Vincent and the Grenadines
	VC Code = "VC"
	// Samoa
	WS Code = "WS"
	// San Marino
	SM Code = "SM"
	// Sao Tome and Principe
	ST Code = "ST"
	// Saudi Arabia
	SA Code = "SA"
	// Senegal
	SN Code = "SN"
	// Serbia
	RS Code = "RS"
	// Seychelles
	SC Code = "SC"
	// Sierra Leone
	SL Code = "SL"
	// Singapore
	SG Code = "SG"
	// Sint Maarten (Dutch part)
	SX Code = "SX"
	// Slovakia
	SK Code = "SK"
	// Slovenia
	SI Code = "SI"
	// Solomon Islands
	SB Code = "SB"
	// Somalia
	SO Code = "SO"
	// South Africa
	ZA Code = "ZA"
	// South Georgia and the South Sandwich Islands
	GS Code = "GS"
	// South Sudan
	SS Code = "SS"
	// Spain
	ES Code = "ES"
	// Sri Lanka
	LK Code = "LK"
	// Sudan
	SD Code = "SD"
	// Suriname
	SR Code = "SR"
	// Svalbard and Jan Mayen
	SJ Code = "SJ"
	// Sweden
	SE Code = "SE"
	// Switzerland
	CH Code = "CH"
	// Syrian Arab Republic
	SY Code = "SY"
	// Taiwan (Province of China)
	TW Code = "TW"
	// Tajikistan
	TJ Code = "TJ"
	// Tanzania, the United Republic of
	TZ Code = "TZ"
	// Thailand
	TH Code = "TH"
	// Timor-Leste
	TL Code = "TL"
	// Togo
	TG Code = "TG"
	// Tokelau
	TK Code = "TK"
	// Tonga
	TO Code = "TO"
	// Trinidad and Tobago
	TT Code = "TT"
	// Tunisia
	TN Code = "TN"
	// Türkiye
	TR Code = "TR"
	// Turkmenistan
	TM Code = "TM"
	// Turks and Caicos Islands
	TC Code = "TC"
	// Tuvalu
	TV Code = "TV"
	// Uganda
	UG Code = "UG"
	// Ukraine
	UA Code = "UA"
	// United Arab Emirates
	AE Code = "AE"
	// United Kingdom
	GB Code = "GB"
	// United States of America
	US Code = "US"
	// United States Minor Outlying Islands
	UM Code = "UM"
	// Uruguay
	UY Code = "UY"
	// Uzbekistan
	UZ Code = "UZ"
	// Vanuatu
	VU Code = "VU"
	// Venezuela, Bolivarian Republic of
	VE Code = "VE"
	// Viet Nam
	VN Code = "VN"
	// Virgin Islands (British)
	VG Code = "VG"
	// Virgin Islands (U.S.)
	VI Code = "VI"
	// Wallis and Futuna
	WF Code = "WF"
	// Western Sahara
	EH Code = "EH"
	// Yemen
	YE Code = "YE"
	// Zambia
	ZM Code = "ZM"
	// Zimbabwe
	ZW Code = "ZW"
)

List of all ISO 3166-2 country codes that we know about.

const (
	EL Code = "EL" // Greece
	XI Code = "XI" // Northern Ireland
	XU Code = "XU" // United Kingdom except Northern Ireland
)

Extension country codes required by some countries for tax purposes.

const CodeEmpty Code = ""

CodeEmpty is used for matching empty codes.

const (
	EU Code = "EU"
)

Union codes

func (Code) Empty added in v0.115.0

func (c Code) Empty() bool

Empty returns true if the code is empty.

func (Code) ISO added in v0.113.0

func (c Code) ISO() ISOCountryCode

ISO is a convenience method to provide the ISO country code of a code.

func (Code) In added in v0.28.2

func (c Code) In(set ...Code) bool

In returns true if the code is contained inside the provided set

func (Code) JSONSchema added in v0.29.0

func (Code) JSONSchema() *jsonschema.Schema

JSONSchema provides a representation of the struct for usage in Schema.

func (Code) String added in v0.27.0

func (c Code) String() string

String provides string representation of code

func (Code) Tax added in v0.113.0

func (c Code) Tax() TaxCountryCode

Tax is a convenience method to provide the tax country code of a code.

func (Code) Validate added in v0.20.0

func (c Code) Validate() error

Validate ensures the code is formatted correctly.

type CountryDef added in v0.29.0

type CountryDef struct {
	// ISO 3166-2 Country code
	Code Code `json:"code" jsonschema:"title=ISO 3166-2 Country Code"`
	// ISO 3166-1 alpha-3 Country code
	Alpha3 string `json:"alpha3" jsonschema:"title=ISO 3166-1 Alpha-3 Country Code"`
	// English name of the country
	Name string `json:"name" jsonschema:"title=Name"`
	// Internet Top-Level-Domain
	TLD string `json:"tld" jsonschema:"title=Top level domain"`
	// When true, the country is an ISO code.
	ISO bool `json:"iso" jsonschema:"title=ISO"`
	// When true, the code can be used for tax purposes.
	Tax bool `json:"tax" jsonschema:"title=Tax"`
	// Indicates that a different code can be used for lookups.
	AltCode Code `json:"alt_code" jsonschema:"title=Tax Code"`
}

CountryDef provides the structure use to define a Country Code definition.

type CountryDefs added in v0.113.0

type CountryDefs []*CountryDef

CountryDefs provides helps for managing the list of countries

func Countries added in v0.113.0

func Countries() CountryDefs

Countries provides an array of country definitions including the official ISO country code, the name in English, the country's top-level-domain name, and if this is an extension or not.

func (CountryDefs) Code added in v0.113.0

func (cdfs CountryDefs) Code(c Code) *CountryDef

Code finds the country definition for the given country code

func (CountryDefs) ISO added in v0.113.0

func (cdfs CountryDefs) ISO() []*CountryDef

ISO provides a list of all the ISO countries.

func (CountryDefs) Len added in v0.113.0

func (cdfs CountryDefs) Len() int

Len provides the length of the country definitions

func (CountryDefs) Tax added in v0.113.0

func (cdfs CountryDefs) Tax() []*CountryDef

Tax provides a list of all the country definitions that can be used for tax purposes.

type ISOCountryCode added in v0.113.0

type ISOCountryCode Code

ISOCountryCode defines an ISO 3166-2 country code.

func (ISOCountryCode) Alpha3 added in v0.113.0

func (c ISOCountryCode) Alpha3() string

Alpha3 provides the ISO 3166-1 alpha-3 country code

func (ISOCountryCode) Code added in v0.113.0

func (c ISOCountryCode) Code() Code

Code provides the Code type for the ISO country code.

func (ISOCountryCode) Empty added in v0.115.0

func (c ISOCountryCode) Empty() bool

Empty returns true if the ISO country code is empty.

func (ISOCountryCode) In added in v0.113.0

func (c ISOCountryCode) In(set ...ISOCountryCode) bool

In returns true if the country code is contained inside the provided set

func (ISOCountryCode) JSONSchema added in v0.113.0

func (ISOCountryCode) JSONSchema() *jsonschema.Schema

JSONSchema provides a representation of the struct for usage in Schema.

func (ISOCountryCode) Name added in v0.113.0

func (c ISOCountryCode) Name() string

Name provides the ISO Country Name for the code

func (ISOCountryCode) String added in v0.113.0

func (c ISOCountryCode) String() string

String provides string representation of the ISO country code

func (ISOCountryCode) Validate added in v0.113.0

func (c ISOCountryCode) Validate() error

Validate ensures the ISO country code is inside the known and valid list of countries.

type TaxCountryCode added in v0.113.0

type TaxCountryCode Code

TaxCountryCode defines a code that may coincide with a country code, but may not always coincide.

func (TaxCountryCode) Code added in v0.113.0

func (c TaxCountryCode) Code() Code

Code provides the Code type for the tax country code.

func (TaxCountryCode) Empty added in v0.115.0

func (c TaxCountryCode) Empty() bool

Empty returns true if the tax country code is empty.

func (TaxCountryCode) In added in v0.113.0

func (c TaxCountryCode) In(set ...TaxCountryCode) bool

In returns true if the tax country code is contained inside the provided set

func (TaxCountryCode) JSONSchema added in v0.113.0

func (TaxCountryCode) JSONSchema() *jsonschema.Schema

JSONSchema provides a representation of the type for usage in Schema.

func (TaxCountryCode) Name added in v0.113.0

func (c TaxCountryCode) Name() string

Name provides the ISO Country Name for the code

func (TaxCountryCode) String added in v0.113.0

func (c TaxCountryCode) String() string

String provides string representation of the tax country code

func (TaxCountryCode) Validate added in v0.113.0

func (c TaxCountryCode) Validate() error

Validate ensures the tax country code is inside the known and valid list of country codes for taxes.

type UnionDef added in v0.209.0

type UnionDef struct {
	// Short identifier for the union.
	Code Code `json:"code" jsonschema:"title=Code"`
	// Name of the union
	Name string `json:"name" jsonschema:"title=Name"`
	// Members defines the list of members of the union by
	// their ISO or Tax country codes. Members may be duplicated
	// if they have left and rejoined the union during a specific
	// period.
	Members []*UnionMember `json:"members" jsonschema:"title=Members"`
}

UnionDef represents the definition of a group of countries with a common political and economic union.

func (*UnionDef) HasMember added in v0.209.0

func (ud *UnionDef) HasMember(c Code) bool

HasMember checks if the given country code is a member of the union at the current point in time.

func (*UnionDef) HasMemberOn added in v0.209.0

func (ud *UnionDef) HasMemberOn(date cal.Date, c Code) bool

HasMemberOn checks if the given country code is a member of the union at a specific point in time.

type UnionDefs added in v0.209.0

type UnionDefs []*UnionDef

UnionDefs is a list of UnionDef objects.

func Unions added in v0.209.0

func Unions() UnionDefs

Unions provides of list of significant political and economic unions that countries may be members of.

func (UnionDefs) Code added in v0.209.0

func (uds UnionDefs) Code(c Code) *UnionDef

Code finds the union definition for the given country code

func (UnionDefs) Len added in v0.209.0

func (uds UnionDefs) Len() int

Len provides the length of the union definitions

type UnionMember added in v0.209.0

type UnionMember struct {
	// ISO 3166-2 Country Code
	Code Code `json:"code" jsonschema:"title=Code"`
	// Alternative code that can be used for lookups
	AltCode Code `json:"alt_code,omitempty" jsonschema:"title=Alt Code"`
	// Date when the state became a member.
	Since cal.Date `json:"since" jsonschema:"title=Since"`
	// Date of departure.
	Until cal.Date `json:"until,omitempty" jsonschema:"title=Until"`
}

UnionMember represents a country that is a member of a union, including the date when the country joined and may have left.

func (*UnionMember) On added in v0.209.0

func (ud *UnionMember) On(date cal.Date) bool

On checks if the given country code is a member of the union at a specific point in time.

Jump to

Keyboard shortcuts

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