Countries

关于每个国家的各种有用信息都被包装成方便的小国家对象。它包括 ISO 3166(国家和州/分区)、ISO 4217(货币)和 E.164(电话号码)的数据。「All sorts of useful information about every country packaged as convenient little country objects. It includes data from ISO 3166 (countries and states/subdivisions ), ISO 4217 (currency), and E.164 (phone numbers).」

Github星跟蹤圖

Countries

Countries is a collection of all sorts of useful information for every country in the ISO 3166 standard. It contains info for the following standards ISO3166-1 (countries), ISO3166-2 (states/subdivisions), ISO4217 (currency) and E.164 (phone numbers). I will add any country based data I can get access to. I hope this to be a repository for all country based information.

Gem Version Build Status Code Climate

Installation

gem install countries

Or you can install via Bundler if you are using Rails. Add this line to your application's Gemfile:

gem 'countries'

And then execute:

$ bundle

Basic Usage

Simply load a new country object using Country.new(alpha2) or the shortcut Country[alpha2]. An example works best.

c = ISO3166::Country.new('US')

Configuration

Country Helper

Some apps might not want to constantly call ISO3166::Country this gem has a
helper that can provide a Country class

# With global Country Helper
c = Country['US']

This will conflict with any existing Country constant

To Use

gem 'countries', require: 'countries/global'

Upgrading to 3.x

We dropped currency support via money by default, see instructions if you are using currency featues

Upgrading Country Helper to > 1.2.0

gem 'countries', require: 'global'

has become

gem 'countries', require: 'countries/global'

Selective Loading of Locales

As of 2.0 you can selectively load locales to reduce memory usage in production.

By default we load I18n.available_locales if I18n is present, otherwise only [:en]. This means almost any rails environment will only bring in its supported translations.

You can add all the locales like this.

ISO3166.configure do

主要指標

概覽
名稱與所有者countries/countries
主編程語言Ruby
編程語言Ruby (語言數: 1)
平台Linux, Mac, Windows
許可證MIT License
所有者活动
創建於2009-12-18 22:42:26
推送於2025-06-04 09:08:04
最后一次提交2025-06-02 14:33:23
發布數108
最新版本名稱v8.0.2 (發布於 )
第一版名稱v0.1.0 (發布於 )
用户参与
星數2.3k
關注者數38
派生數675
提交數1.8k
已啟用問題?
問題數310
打開的問題數22
拉請求數501
打開的拉請求數5
關閉的拉請求數101
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?