nationid - v2.2.1
    Preparing search index...

    Function getCountryInfo

    • Returns the localized CountryInfo for code.

      Resolves the country name via Intl.DisplayNames (CLDR data shipped with the runtime) and computes the flag emoji from the ISO code. The alpha3 field comes from a hand-maintained ISO 3166-1 alpha-3 table.

      Parameters

      • code: CountryCode

        One of the 34 supported CountryCode values.

      • locale: string = DEFAULT_LOCALE

        Any BCP 47 language tag (default "en"). Unsupported locales fall back to whatever the runtime's Intl.DisplayNames picks.

      Returns CountryInfo

      A CountryInfo object. Always defined for valid CountryCode inputs since the alpha-3 table covers them all.

      import { getCountryInfo } from "nationid/catalog";

      getCountryInfo("MX", "es");
      // { code: "MX", alpha3: "MEX", name: "México", flag: "🇲🇽" }

      getCountryInfo("BR", "pt");
      // { code: "BR", alpha3: "BRA", name: "Brasil", flag: "🇧🇷" }

      getCountryInfo("GB"); // default locale "en"
      // { code: "GB", alpha3: "GBR", name: "United Kingdom", flag: "🇬🇧" }