Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Ruby gem with ISO 639-1 and ISO 639-2 language code entries and convenience methods.

License

NotificationsYou must be signed in to change notification settings

xwmx/iso-639

Repository files navigation

Build StatusGem VersionGem Downloads

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

TheISO 639-1 specification uses atwo-letter code to identify a language and is often the recommended way toidentify languages in computer applications. The ISO 639-1 specification coversmost developed and widely used languages.

TheISO 639-2(Wikipedia) specification uses athree-letter code, is used primarily in bibliography and terminology andcovers many more languages than the ISO 639-1 specification.

Installation

To install fromRubyGems:

gem install iso-639

To install withBundler, add the following to yourGemfile:

gem'iso-639'

Then runbundle install

Usage

require'iso-639'

To find a language entry:

# by alpha-2 or alpha-3 codeISO_639.find_by_code("en")# orISO_639.find("en")# by English nameISO_639.find_by_english_name("Russian")# by French nameISO_639.find_by_french_name("français")

TheISO_639.search class method searches across all fields and willmatch names in cases where a record has multiple names. This methodalways returns an array of 0 or more results. For example:

ISO_639.search("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"]@entry.alpha3_bibliographic# => "slo"@entry.alpha3# shortcut for #alpha3_bibliographic# => "slo"@entry.alpha3_terminologic# => "slk"@entry.alpha2# => "sk"@entry.english_name# => "Slovak"@entry.french_name# => "slovaque"

The full data set is available through theISO_639::ISO_639_1 andISO_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 afuture version unintentionally.
  • Commit, do not mess with rakefile, version, or history.(if you want to have your own version, that is fine butbump version in a commit by itself I can ignore when I pull)
  • Send me a pull request. Bonus points for topic branches.

Copyright

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

About

Ruby gem with ISO 639-1 and ISO 639-2 language code entries and convenience methods.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp