Lande
Lande
Pakken indeholder 248+ lande med fuld ISO 3166-1-metadata.
Landeegenskaber
Hvert land har foelgende felter:
| Felt | Beskrivelse |
|---|---|
alpha2Code | ISO 3166-1 alpha-2-kode (f.eks. "US") |
alpha3Code | ISO 3166-1 alpha-3-kode (f.eks. "USA") |
numericCode | ISO 3166-1 numerisk kode (f.eks. 840) |
nativeName | Oprindeligt landenavn |
capital | Hovedstad |
mainLanguage | Primaer sprogkode |
languages | Liste over talte sprogkoder |
tld | Topdomaene (f.eks. ".us") |
callingCode | Internationalt opkaldsnummer (f.eks. 1) |
continent | Kontinent-identifikator |
currency | Primaer valutakode |
Opslag efter kode
Alpha-2-kode
GoDartTypeScript
import { getCountryByAlpha2 } from 'infobits-intl';
const country = getCountryByAlpha2('US');
console.log(country?.nativeName); // United States
console.log(country?.capital); // Washington, D.C.Alpha-3-kode
GoDartTypeScript
import { getCountryByAlpha3 } from 'infobits-intl';
const country = getCountryByAlpha3('USA');
console.log(country?.alpha2Code); // USNumerisk kode (kun Dart)
final country = Country.fromNumericCode(840);
print(country?.nativeName); // United States
Liste over alle lande
GoDartTypeScript
import { countries, CountryCode } from 'infobits-intl';
const allCountries = Object.values(countries);
console.log(allCountries.length);Filtrer efter kontinent
GoDartTypeScript
import { getCountriesByContinent } from 'infobits-intl';
const european = getCountriesByContinent('europe');
european.forEach(c => console.log(c.nativeName));SVG-flag
Hvert land har et inline SVG-flag tilgaengeligt som en streng.
GoDartTypeScript
import { getFlag, flags } from 'infobits-intl';
// Brug opslagsfunktionen
const svg = getFlag('US');
// Eller tilg map'et direkte
const svgDirect = flags['US'];Emoji-flag
GoDartTypeScript
import { getEmojiFlag } from 'infobits-intl';
console.log(getEmojiFlag('US'));Landemetadata
GoDartTypeScript
import { getCountryByAlpha2 } from 'infobits-intl';
const country = getCountryByAlpha2('JP');
console.log(country?.callingCode); // 81
console.log(country?.tld); // .jp
console.log(country?.currency); // JPY
console.log(country?.continent); // asia
console.log(country?.mainLanguage); // ja