API Reference
API Reference
A complete reference of all public APIs available in each package.
Types
Country
| Field | Type | Description |
|---|---|---|
id | string | Unique identifier (e.g. "unitedStates") |
alpha2Code | string | ISO 3166-1 alpha-2 (e.g. "US") |
alpha3Code | string | ISO 3166-1 alpha-3 (e.g. "USA") |
numericCode | number | ISO 3166-1 numeric (e.g. 840) |
nativeName | string | Native country name |
capital | string | Capital city |
mainLanguage | string | Primary language code |
languages | string[] | All spoken language codes |
tld | string | Top-level domain |
callingCode | number | International calling code |
continent | string | Continent identifier |
currency | string | Currency code |
Language
| Field | Type | Description |
|---|---|---|
id | string | Unique identifier (e.g. "english") |
code | string | ISO 639-1 code (e.g. "en") |
nativeName | string | Name in the language itself |
dialects | LanguageDialect[] | Regional variations |
defaultFlagCode | string? | Country code for representative flag |
LanguageDialect
| Field | Type | Description |
|---|---|---|
id | string | Unique identifier |
code | string | Dialect code |
nativeName | string | Native name of the dialect |
flagCode | string? | Country code for the dialect's flag |
Currency
| Field | Type | Description |
|---|---|---|
id | string | Unique identifier (e.g. "usd") |
code | string | ISO 4217 code (e.g. "USD") |
nativeName | string | Singular name (e.g. "US Dollar") |
nativeNamePlural | string | Plural name (e.g. "US Dollars") |
symbol | string | Currency symbol (e.g. "$") |
Continent
| Field | Type | Description |
|---|---|---|
id | string | Unique identifier (e.g. "europe") |
code | string | Two-letter code (e.g. "EU") |
name | string | English display name |
Lookup Functions
Countries
// Go
intl.CountryByAlpha2(code string) (Country, bool)
intl.CountryByAlpha3(code string) (Country, bool)
intl.AllCountries() []Country
intl.CountriesByContinent(continent string) []CountryLanguages
// Go
intl.LanguageByCode(code string) (Language, bool)
intl.AllLanguages() []LanguageCurrencies
// Go
intl.CurrencyByCode(code string) (Currency, bool)
intl.AllCurrencies() []CurrencyContinents
// Go
intl.ContinentByCode(code string) (Continent, bool)
intl.AllContinents() []ContinentFlags
// Go
intl.GetFlag(alpha2 string) (string, bool)
intl.Flags // map[string]stringEmoji Flags
// Go
code.EmojiFlag() string // on CountryCodeEnums / Constants
Each package provides type-safe constants for all codes:
// Go — typed string constants
intl.CountryUS // CountryCode("US")
intl.LanguageFR // LanguageCode("FR")
intl.CurrencyEUR // CurrencyCode("EUR")
intl.ContinentEU // ContinentCode("EU")Translation Functions
All translation functions take an entity code and a locale code, returning the localized name.
Available locales: 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)Translation Maps
For bulk access, raw translation maps are available:
// Go
i18n.CountriesTranslations // map[string]map[string]string
i18n.LanguagesTranslations
i18n.CurrenciesTranslations
i18n.ContinentsTranslations
i18n.CapitalsTranslations