countries-list vs country-code-lookup vs country-data vs country-list vs i18n-iso-countries
国名データライブラリ
countries-listcountry-code-lookupcountry-datacountry-listi18n-iso-countries類似パッケージ:

国名データライブラリ

これらのライブラリは、国名、国コード、国に関する情報を提供するために使用されます。開発者は、国に関連するデータを簡単に取得し、アプリケーションに統合することができます。これにより、国に基づく機能を持つアプリケーションの開発が容易になります。

npmのダウンロードトレンド

3 年

GitHub Starsランキング

統計詳細

パッケージ
ダウンロード数
Stars
サイズ
Issues
公開日時
ライセンス
countries-list01,308274 kB91ヶ月前MIT
country-code-lookup08761.4 kB58日前MIT
country-data0518-359年前MIT
country-list028216.9 kB17ヶ月前MIT
i18n-iso-countries0893624 kB541年前MIT

機能比較: countries-list vs country-code-lookup vs country-data vs country-list vs i18n-iso-countries

データの種類

  • countries-list:

    国名のリストを提供し、各国のISOコードを含んでいます。シンプルで使いやすいデータ構造です。

  • country-code-lookup:

    国コードと国名のマッピングを提供します。特に、ISO 3166-1 alpha-2およびalpha-3コードをサポートしています。

  • country-data:

    国に関する詳細なデータを提供します。人口、面積、通貨、言語などの情報が含まれています。

  • country-list:

    国名のリストを提供しますが、詳細な情報は含まれていません。シンプルなリストが必要な場合に便利です。

  • i18n-iso-countries:

    国名を多言語で提供します。国際化対応のアプリケーションに最適です。

使用シナリオ

  • countries-list:

    国名を表示する必要があるフォームやドロップダウンリストに適しています。

  • country-code-lookup:

    国コードを使用して国情報を取得するAPIと連携する際に便利です。

  • country-data:

    国に関する詳細な情報を表示する必要があるダッシュボードやレポートに適しています。

  • country-list:

    単純な国名リストが必要な場合、例えば、ユーザーの国を選択させる場合に適しています。

  • i18n-iso-countries:

    多言語対応のアプリケーションで国名を表示するために使用します。

国際化対応

  • countries-list:

    国名は英語で提供されますが、他の言語には対応していません。

  • country-code-lookup:

    国名は英語で提供され、国コードに基づく情報を提供します。

  • country-data:

    国に関する情報は英語で提供されますが、他の言語には対応していません。

  • country-list:

    国名は英語で提供され、他の言語には対応していません。

  • i18n-iso-countries:

    多言語対応で、各国の国名を異なる言語で取得することができます。

メンテナンス

  • countries-list:

    シンプルな構造のため、メンテナンスが容易です。

  • country-code-lookup:

    国コードの変更に対応するため、定期的な更新が必要です。

  • country-data:

    国に関するデータの更新が必要ですが、詳細な情報を提供するために維持されています。

  • country-list:

    簡単なリストのため、メンテナンスはほとんど不要です。

  • i18n-iso-countries:

    国際化のニーズに応じて、定期的な更新が必要です。

学習曲線

  • countries-list:

    非常にシンプルで、すぐに使い始めることができます。

  • country-code-lookup:

    国コードの概念を理解する必要がありますが、比較的簡単に学べます。

  • country-data:

    詳細な情報を扱うため、少し学習が必要ですが、使いやすいです。

  • country-list:

    シンプルなリストのため、すぐに理解できます。

  • i18n-iso-countries:

    多言語対応のため、国際化の概念を理解する必要がありますが、使いやすいです。

選び方: countries-list vs country-code-lookup vs country-data vs country-list vs i18n-iso-countries

  • countries-list:

    国名のリストを簡単に取得したい場合に適しています。シンプルで軽量なライブラリです。

  • country-code-lookup:

    国コードを国名にマッピングしたい場合に最適です。特に、国コードを使用して国情報を取得する必要がある場合に便利です。

  • country-data:

    国に関する詳細な情報が必要な場合に選択すべきです。人口、面積、通貨などの情報を提供します。

  • country-list:

    国名のリストを取得したいが、特定の国コードの情報が必要ない場合に適しています。シンプルな国名リストを提供します。

  • i18n-iso-countries:

    国名の国際化が必要な場合に最適です。多言語対応のアプリケーションで国名を表示するための便利な機能を提供します。

countries-list のREADME

Countries, Languages & Continents data

Monthly Downloads NPM Packagist CI: JS CI: PHP Twitter

Continents & countries: ISO 3166-1 alpha-2 code (with alpha-2 to alpha-3 set), name, ISO 639-1 languages, capital and ISO 4217 currency codes, native name, calling codes. Lists are available in JSON, CSV and SQL formats. Also, contains separate JSON files with additional country Emoji flags data.

Version 3.0: Breaking changes

Version 3 comes with some data structure changes. It was completely reworked under the hood with TypeScript, ESM exports and Turborepo file structure.

Everything is strongly typed so you can easily use data with auto-complete in your IDE.

Note: If your projects depend on the old structure, carefully specify required versions in your dependencies.

Installation

Package is available via:

  • Bun bun add countries-list
  • NPM npm install countries-list
  • Composer / Packagist composer require annexare/countries-list

Usage (version 3.x)

Module exports continents, countries, languages and utility functions.

// Interfaces and types
import type {
  ICountry,
  ICountryData,
  ILanguage,
  TContinentCode,
  TCountryCode,
  TLanguageCode,
} from 'countries-list'

// Main data and utils
import { continents, countries, languages } from 'countries-list'
// Utils
import { getCountryCode, getCountryData, getCountryDataList, getEmojiFlag } from 'countries-list'

// Minimal data in JSON
import countries2to3 from 'countries-list/minimal/countries.2to3.min.json'
import countries3to2 from 'countries-list/minimal/countries.3to2.min.json'
import languageNames from 'countries-list/minimal/languages.native.min'

getCountryCode('Ukraine') // 'UA'
getCountryCode('Україна') // 'UA'
getCountryData('UA') // ICountryData

Built files are in the dist directory of this repository, and packages/countries directory contains source data.

Note: JS build contains ES modules, CommonJS and IIFE (for now)

  • CJS cjs/index.js
  • ESM mjs/index.js
  • IIFE index.iife.js

Data structure examples

const continents = {
  AF: 'Africa',
  AN: 'Antarctica',
  AS: 'Asia',
  EU: 'Europe',
  NA: 'North America',
  OC: 'Oceania',
  SA: 'South America',
}

const countries = {
  // ...
  UA: {
    name: 'Ukraine',
    native: 'Україна',
    phone: [380],
    continent: 'EU',
    capital: 'Kyiv',
    currency: ['UAH'],
    languages: ['uk'],
  },
  // ...
}

const languages = {
  // ...
  uk: {
    name: 'Ukrainian',
    native: 'Українська',
  },
  ur: {
    name: 'Urdu',
    native: 'اردو',
    rtl: 1,
  },
  // ...
}

Contributing to this repository

Everything is generated from strongly typed files in packages/countries/src, including SQL file.

Everything in dist is generated, so please make data related changes ONLY to files from packages/countries, commit them. Use bun run build (or turbo build, turbo test) command to build/test generated files.

Credits

Prepared by Annexare Studio from different public sources. Feel free to use it as you need in your apps or send updates into this public repository. It's under MIT license.