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.
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