nationid - v2.2.1
    Preparing search index...

    Function countryName

    • Resolves the localized country name for code.

      Falls back to the ISO code itself if the runtime cannot resolve the name (e.g. an extremely minimal Node distribution with no ICU). This keeps the library usable even on legacy runtimes — names just look like "MX" until the runtime is upgraded.

      Parameters

      • code: string

        ISO 3166-1 alpha-2 code.

      • locale: string = DEFAULT_LOCALE

        Any BCP 47 language tag (default "en").

      Returns string

      The country name in the requested locale, or the ISO code as fallback.

      import { countryName } from "nationid/catalog";

      countryName("MX", "es"); // "México"
      countryName("MX", "fr"); // "Mexique"
      countryName("MX", "zh-CN"); // "墨西哥"