Reference · Countries and lookup tools
countryNamefunction
A country's name in English or Japanese.
Import it
import { countryName } from "@johnmorrisdotca/kuni";
Definition
function countryName(code: string, language?: Language, options?: CountryNameOptions): string | null
Parameters
| Name | Type | Description |
|---|---|---|
code | string | Any code |
language (optional) | "en" | "ja" | "en" (the default) or "ja". |
options (optional) | CountryNameOptions |
|
Returns
string | null
The name; null for a code that is not a country, or a language that is not one of the two.
Examples
import { countryName } from "@johnmorrisdotca/kuni";
console.log(countryName("US")); // "United States"
console.log(countryName("US", "ja", { short: true })); // "アメリカ"
console.log(countryName("GB", "en", { short: true })); // "UK"
console.log(countryName("XX")); // nullUnited States
アメリカ
UK
nullWhat it prints (run when this page was built)