Skip to content
Ruby: country/language names and 2-letter-code pairs, in 85 languages, for country/language i18n
Latest commit 19b5689 Feb 19, 2016 @grosser Merge pull request #23 from fnix/i18n-separator-2
recognises locales separated with -
Failed to load latest commit information.
cache/file_data_provider Update cached file_data_provider Mar 24, 2015
example_output some more example output to show the possibilities Jan 10, 2009
lib recognises locales separated with - Feb 19, 2016
spec recognises locales separated with - Feb 19, 2016
.gitignore added gemspec Jan 18, 2009
.travis.yml fix travis Feb 18, 2016
Gemfile simplify and update Jun 16, 2014
Rakefile Fix for countries with apostrophes Mar 24, 2015 Add README info about sorting countries alphabetically Feb 4, 2015
gem-public_cert.pem update cert Mar 15, 2014
i18n_data.gemspec drop ree Apr 15, 2015

  • Present users coutries/languages in their language
  • Convert a country/language-name to its 2-letter-code
  • List of 2-letter-code/name pairs for all countries/languages in all languages


Through pkg-isocodes:

  • 185 Language codes (iso 639 - 2 letter) in 68 Languages
  • 246 Country codes (iso 3166 - 2 letter) in 86 Languages
  • contry specific codes e.g. zh_TW are also available, have a look at the isocodes website for all options


gem install i18n_data


require 'i18n_data'
I18nData.languages        # {"DE"=>"German",...}
I18nData.languages('DE')  # {"DE"=>"Deutsch",...}
I18nData.languages('FR')  # {"DE"=>"Allemand",...}

I18nData.countries        # {"DE"=>"Germany",...}
I18nData.countries('DE')  # {"DE"=>"Deutschland",...}

I18nData.language_code('German')       # DE
I18nData.language_code('Deutsch')      # DE
I18nData.language_code('Allemand')     # DE

I18nData.country_code('Germany')       # DE
I18nData.country_code('Deutschland')   # DE

Data Providers

  • FileDataProvider: FAST (default) (loading data from cache-files)
  • LiveDataProvider: SLOW (fetching up-to-date data from svn repos)


  • update FileDataProvider caches after each code-change to make changes available to users rake write_cache_for_file_data_provider
  • FileDataProvider tests might fail if caches are not updates

Alphabetical localized sorting

If you would like to have the countries list sorted alphabetically in different languages there is a gem called sort_alphabetical for that.


  • include other language/country code formats (3-letter codes...) ?
  • parse list of files on isocodes for write_cache instead of hardcoding country-specific ones



Michael Grosser
License: MIT
Build Status

Something went wrong with that request. Please try again.