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?
已存档?
是复刻?
已锁定?
是镜像?
是私有?