class ISO_639

Constants

INVERTED_INDEX

An inverted index generated from the ISO_639_2 data. Used for searching all words and codes in all fields.

ISO_639_1

The ISO 639-1 dataset as an array of entries. Each entry is an array with the following format:

  • [0]: an ISO 369-2 alpha-3 (bibliographic) code

  • [1]: an ISO 369-2 alpha-3 (terminologic) code (when given)

  • [2]: an ISO 369-1 alpha-2 code (when given)

  • [3]: an English name

  • [4]: a French name

ISO_639_2

Load the ISO 639-2 dataset as an array of entries. Each entry is an array with the following format:

  • [0]: an alpha-3 (bibliographic) code

  • [1]: an alpha-3 (terminologic) code (when given)

  • [2]: an alpha-2 code (when given)

  • [3]: an English name

  • [4]: a French name of a language

Dataset Source: www.loc.gov/standards/iso639-2/ascii_8bits.html www.loc.gov/standards/iso639-2/ISO-639-2_utf-8.txt

Public Class Methods

find(code)
Alias for: find_by_code
find_by_code(code) click to toggle source

Returns the entry array for an alpha-2 or alpha-3 code

# File lib/iso-639.rb, line 71
def find_by_code(code)
  return if code.nil?

  case code.length
  when 3, 7
    ISO_639_2.detect do |entry|
      entry if [entry.alpha3, entry.alpha3_terminologic].include?(code)
    end
  when 2
    ISO_639_1.detect do |entry|
      entry if entry.alpha2 == code
    end
  end
end
Also aliased as: find
find_by_english_name(name) click to toggle source

Returns the entry array for a language specified by its English name.

# File lib/iso-639.rb, line 89
def find_by_english_name(name)
  ISO_639_2.detect do |entry|
    entry if entry.english_name == name
  end
end
find_by_french_name(name) click to toggle source

Returns the entry array for a language specified by its French name.

# File lib/iso-639.rb, line 96
def find_by_french_name(name)
  ISO_639_2.detect do |entry|
    entry if entry.french_name == name
  end
end

Public Instance Methods

alpha2() click to toggle source

The entry’s alpha-2 code (when given)

# File lib/iso-639.rb, line 128
def alpha2
  self[2]
end
alpha3()
alpha3_bibliographic() click to toggle source

The entry’s alpha-3 bibliotigraphic code.

# File lib/iso-639.rb, line 116
def alpha3_bibliographic
  self[0]
end
Also aliased as: alpha3
alpha3_terminologic() click to toggle source

The entry’s alpha-3 terminologic (when given)

# File lib/iso-639.rb, line 123
def alpha3_terminologic
  self[1]
end
english_name() click to toggle source

The entry’s english name.

# File lib/iso-639.rb, line 133
def english_name
  self[3]
end
french_name() click to toggle source

The entry’s french name.

# File lib/iso-639.rb, line 138
def french_name
  self[4]
end