本文へ移動

Kuni国

国、コード、名前、行政区画を調べ、必要なときに国のデータを読み込み、標準の国のカードを表示できます。

「国(くに)」は、国を表す日本語です。 名前について(英語)

目次

リファレンス · 国と検索の道具

countryName関数

リファレンスの説明と例は英語です。見出しと目次は日本語です。

A country's name in English or Japanese.

インポート

import { countryName } from "@johnmorrisdotca/kuni";

定義

function countryName(code: string, language?: Language, options?: CountryNameOptions): string | null

引数

名前型説明
codestring

Any code country() takes.

language (省略可)"en" | "ja"

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

options (省略可)CountryNameOptions

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

戻り値

string | null

The name; null for a code that is not a country, or a language that is not one of the two.

例

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

出力(このページを作ったときに実行した結果)

ソースを見るGitHub で編集@johnmorrisdotca/kuni 1.4.0 のソースから作成しました。

この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。