API-reference
API-reference
En komplet reference over alle offentlige API'er tilgaengelige i hver pakke.
Typer
Country
| Felt | Type | Beskrivelse |
|---|---|---|
id | string | Unik identifikator (f.eks. "unitedStates") |
alpha2Code | string | ISO 3166-1 alpha-2 (f.eks. "US") |
alpha3Code | string | ISO 3166-1 alpha-3 (f.eks. "USA") |
numericCode | number | ISO 3166-1 numerisk (f.eks. 840) |
nativeName | string | Oprindeligt landenavn |
capital | string | Hovedstad |
mainLanguage | string | Primaer sprogkode |
languages | string[] | Alle talte sprogkoder |
tld | string | Topdomaene |
callingCode | number | Internationalt opkaldsnummer |
continent | string | Kontinent-identifikator |
currency | string | Valutakode |
Language
| Felt | Type | Beskrivelse |
|---|---|---|
id | string | Unik identifikator (f.eks. "english") |
code | string | ISO 639-1-kode (f.eks. "en") |
nativeName | string | Navn paa selve sproget |
dialects | LanguageDialect[] | Regionale varianter |
defaultFlagCode | string? | Landekode for repraesentativt flag |
LanguageDialect
| Felt | Type | Beskrivelse |
|---|---|---|
id | string | Unik identifikator |
code | string | Dialektkode |
nativeName | string | Oprindeligt navn paa dialekten |
flagCode | string? | Landekode for dialektens flag |
Currency
| Felt | Type | Beskrivelse |
|---|---|---|
id | string | Unik identifikator (f.eks. "usd") |
code | string | ISO 4217-kode (f.eks. "USD") |
nativeName | string | Ental-navn (f.eks. "US Dollar") |
nativeNamePlural | string | Flertal-navn (f.eks. "US Dollars") |
symbol | string | Valutasymbol (f.eks. "$") |
Continent
| Felt | Type | Beskrivelse |
|---|---|---|
id | string | Unik identifikator (f.eks. "europe") |
code | string | Tobogstavskode (f.eks. "EU") |
name | string | Engelsk visningsnavn |
Opslagsfunktioner
Lande
// Go
intl.CountryByAlpha2(code string) (Country, bool)
intl.CountryByAlpha3(code string) (Country, bool)
intl.AllCountries() []Country
intl.CountriesByContinent(continent string) []CountrySprog
// Go
intl.LanguageByCode(code string) (Language, bool)
intl.AllLanguages() []LanguageValutaer
// Go
intl.CurrencyByCode(code string) (Currency, bool)
intl.AllCurrencies() []CurrencyKontinenter
// Go
intl.ContinentByCode(code string) (Continent, bool)
intl.AllContinents() []ContinentFlag
// Go
intl.GetFlag(alpha2 string) (string, bool)
intl.Flags // map[string]stringEmoji-flag
// Go
code.EmojiFlag() string // on CountryCodeEnums / Konstanter
Hver pakke tilbyder typesikre konstanter for alle koder:
// Go — typed string constants
intl.CountryUS // CountryCode("US")
intl.LanguageFR // LanguageCode("FR")
intl.CurrencyEUR // CurrencyCode("EUR")
intl.ContinentEU // ContinentCode("EU")Oversaettelsesfunktioner
Alle oversaettelsesfunktioner tager en enhedskode og en lokalitetskode og returnerer det lokaliserede navn.
Tilgaengelige lokaliteter: da, de, en, es, fr, it, zh
// Go — all in the i18n sub-package
i18n.GetCountriesName(code, locale string) (string, bool)
i18n.GetLanguagesName(code, locale string) (string, bool)
i18n.GetCurrenciesName(code, locale string) (string, bool)
i18n.GetContinentsName(code, locale string) (string, bool)
i18n.GetCapitalsName(code, locale string) (string, bool)Oversaettelsesmaps
For masseadgang er de raa oversaettelsesmaps tilgaengelige:
// Go
i18n.CountriesTranslations // map[string]map[string]string
i18n.LanguagesTranslations
i18n.CurrenciesTranslations
i18n.ContinentsTranslations
i18n.CapitalsTranslations