Module: Iso639
- Defined in:
- lib/iso639.rb,
lib/iso639/version.rb,
lib/iso639/language.rb,
lib/iso639/insensitive_hash.rb
Overview
Public: Various methods useful for performing ISO-639 language code lookup either given their ISO-639-1 or ISO-639-2 character code value or from human input.
Language code mappings came from loc.gov/standards/iso639-2/ISO-639-2_utf-8.txt
Examples
Iso639["en"] # => "English"
Iso639["en"].alpha2 # => "en"
Iso639["en"].alpha3 # => "eng"
Iso639["en"].alpha3_bibliographic # => "eng"
Iso639["en"].alpha3_terminology # => "eng"
Iso639["en"].name # => "English"
Iso639["en"].english_name # => "English"
Iso639["en"].french_name # => "anglais"
Iso639["German"] # => "German"
Iso639["German"].alpha2 # => "de"
Iso639["German"].alpha3 # => "ger"
Iso639["German"].alpha3_bibliographic # => "ger"
Iso639["German"].alpha3_terminology # => "deu"
Iso639["German"].name # => "German"
Iso639["German"].english_name # => "German"
Iso639["German"].french_name # => "allemand"
Defined Under Namespace
Classes: InsensitiveHash, Language
Constant Summary collapse
- LanguagesByAlpha2 =
InsensitiveHash.new
- LanguagesByAlpha3Bibliographic =
LanguagesByAlpha3 = InsensitiveHash.new
- LanguagesByAlpha3Terminology =
InsensitiveHash.new
- LanguagesByEnglishName =
LanguagesByName = InsensitiveHash.new
- LanguagesByFrenchName =
InsensitiveHash.new
- VERSION =
"1.3.3"
Class Method Summary collapse
-
.[](lookup) ⇒ Object
Public: Find a language by any common lookup value.
Class Method Details
.[](lookup) ⇒ Object
Public: Find a language by any common lookup value
lookup - A String representing an alpha-2, alpha-3, or language name
Examples
Iso639["en"] # => "English"
Iso639["en"].alpha3 # => "eng"
Iso639["English"].alpha2 # => "en"
Iso639["FRENCH"].alpha3 # => "fre"
Iso639["deu"].alpha3 # => "ger"
Returns an Iso639::Language object
61 62 63 64 65 66 67 |
# File 'lib/iso639.rb', line 61 def self.[](lookup) LanguagesByAlpha2[lookup] || LanguagesByAlpha3Bibliographic[lookup] || LanguagesByAlpha3Terminology[lookup] || LanguagesByEnglishName[lookup] || LanguagesByFrenchName[lookup] end |