本文へ移動

Kuni国

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

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

目次

リファレンス · すべての行政区画

Subdivision型

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

A subdivision of a country (a state, a province, a prefecture), with its ISO 3166-2 code, as the lookups hand it out (frozen).

インポート

import type { Subdivision } from "@johnmorrisdotca/kuni/subdivisions";

ほかのエクスポート元: @johnmorrisdotca/kuni/load, @johnmorrisdotca/kuni

定義

interface Subdivision {
    code: string;
    country: string;
    shortCode: string;
    type: SubdivisionType | null;
    level: 1 | 2 | 3;
    parent?: string;
    name: {
        en: string;
        ja: string | null;
    };
    reading?: string;
}

メンバー

名前型説明
codestring

ISO 3166-2, always in full: "JP-13", "CA-ON", "US-NY"

countrystring

ISO 3166-1 alpha-2 of the country it is in: "JP"

shortCodestring

The part after the hyphen: "13", "ON", "NY"

type"atoll" | "autonomous-community" | "autonomous-region" | "borough" | "canton" | "capital-district" | "circuit" | "city" | "council-area" | "country" | "county" | "department" | "district" | "division" | "emirate" | "governorate" | "island" | "krai" | "metropolis" | "municipality" | "oblast" | "parish" | "prefecture" | "principal-area" | "province" | "quarter" | "region" | "republic" | "special-administrative-region" | "state" | "territory" | "unitary-authority" | "urban-prefecture" | "voivodeship" | "zone" | null

What kind of place it is; null when no source says

level2 | 1 | 3

1 for a country's first division; 2 and 3 for those inside one (France's departments)

parent (省略可)string | undefined

The code of the subdivision it is inside, for levels 2 and 3: "FR-ARA" for "FR-01"

name{ en: string; ja: string | null; }

ja is null where no source has a Japanese name, never a guess

reading (省略可)string | undefined

The name in hiragana, for Japan's prefectures: "とうきょうと"

例

import type { Subdivision } from "@johnmorrisdotca/kuni/subdivisions";
import { subdivision } from "@johnmorrisdotca/kuni/subdivisions";

const value: Subdivision = subdivision("JP-13")!;
console.log(typeof value === "object" ? Object.keys(value).slice(0,6) : value);
[ 'code', 'country', 'shortCode', 'type', 'level', 'name' ]

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

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

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