Skip to the content

Kuni国

Look up countries, codes, names and subdivisions, load country data on demand and mount a native country card.

Kuni (国) is Japanese for a country. About the name

Contents

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

NameTypeDescription
codestring

Any code country() takes.

language (optional)"en" | "ja"

"en" (the default) or "ja".

options (optional)CountryNameOptions

short: true for the short form where CLDR has one ("UK", アメリカ).

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"));                         // null
United States
アメリカ
UK
null

What it prints (run when this page was built)

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/kuni 1.4.0.