Ruby gem with ISO 639-1 and ISO 639-2 language code entries and convenience methods
Latest commit 24a6755 Jun 26, 2016 @alphabetum Bump version to 0.2.8.
Failed to load latest commit information.
lib Refactor `ISO_639.[]` to reduce the number of Array allocations. Jun 25, 2016
test Add `Bundler.setup` to test/allocation_stats. Jun 26, 2016
.document Rename README.markdown to the more conventional May 21, 2016
.gitignore Add '.bundle' to .gitignore May 8, 2016
.rubocop.yml Configure rubocop to prefer `alias_method`. Jun 7, 2016
.rubocop_todo.yml Freeze mutable objects assigned to constants. Jun 22, 2016
Gemfile Add gem descriptions and URLs to Gemfile. Jun 26, 2016
Gemfile.lock Add `Bundler.setup` to test/allocation_stats. Jun 26, 2016
LICENSE initial import and gem creation Jan 14, 2010 Rename README.markdown to the more conventional May 21, 2016
iso-639.gemspec Bump version to 0.2.8. Jun 26, 2016

ISO 639

A Ruby gem that provides the ISO 639-2 and ISO 639-1 data sets along with some convenience methods for accessing different entries and entry fields. The data comes from the LOC ISO 639-2 UTF-8 data set.

To install:

gem install iso-639

The ISO 639-1 specification uses a two-letter code to identify a language and is often the recommended way to identify languages in computer applications. The ISO 639-1 specification covers most developed and widely used languages.

The ISO 639-2 (Wikipedia) specification uses a three-letter code, is used primarily in bibliography and terminology and covers many more languages than the ISO 639-1 specification.


require 'iso-639'

To find a language entry:

# by alpha-2 or alpha-3 code
# or
# by English name
# by French name

The class method searches across all fields and will match names in cases where a record has multiple names. This method always returns an array of 0 or more results. For example:"spanish")
# => [["spa", "", "es", "Spanish; Castilian", "espagnol; castillan"]]

Entries are arrays with convenience methods for accessing fields:

@entry = ISO_639.find("slo")
# => ["slo", "slk", "sk", "Slovak", "slovaque"]
# => "slo"
@entry.alpha3 # shortcut for #alpha3_bibliographic
# => "slo"
# => "slk"
# => "sk"
# => "Slovak"
# => "slovaque"

The full data set is available through the ISO_639::ISO_639_1 and ISO_639::ISO_639_2 constants.

Note on Patches/Pull Requests

  • Fork the project.
  • Make your feature addition or bug fix.
  • Add tests for it. This is important so I don't break it in a future version unintentionally.
  • Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
  • Send me a pull request. Bonus points for topic branches.


Copyright (c) 2010 William Melody. See LICENSE for details.