diff --git a/data/dump b/data/dump index c1f2aa8..52efe1f 100644 Binary files a/data/dump and b/data/dump differ diff --git a/lib/language_list.rb b/lib/language_list.rb index 4b1386d..fa3f689 100644 --- a/lib/language_list.rb +++ b/lib/language_list.rb @@ -2,13 +2,15 @@ module LanguageList class LanguageInfo - attr_reader :name, :iso_639_3, :iso_639_1, :type + attr_reader :name, :iso_639_3, :iso_639_1, :iso_639_2b, :iso_639_2t, :type def initialize(options) @name = options[:name] @common_name = options[:common_name] @iso_639_3 = options[:iso_639_3] @iso_639_1 = options[:iso_639_1] + @iso_639_2b = options[:iso_639_2b] + @iso_639_2t = options[:iso_639_2t] @common = options[:common] @type = options[:type] end @@ -47,13 +49,25 @@ def self.find_by_iso_639_3(code) LanguageList::BY_ISO_639_3[code] end + def self.find_by_iso_639_2b(code) + LanguageList::BY_ISO_639_2B[code] + end + + def self.find_by_iso_639_2t(code) + LanguageList::BY_ISO_639_2T[code] + end + def self.find_by_name(name) LanguageList::BY_NAME[name.downcase] end def self.find(code) code.downcase! - find_by_iso_639_1(code) || find_by_iso_639_3(code) || find_by_name(code) + find_by_iso_639_1(code) || + find_by_iso_639_3(code) || + find_by_iso_639_2b(code) || + find_by_iso_639_2t(code) || + find_by_name(code) end end @@ -71,10 +85,14 @@ def self.find(code) BY_NAME = {} BY_ISO_639_1 = {} BY_ISO_639_3 = {} + BY_ISO_639_2B = {} + BY_ISO_639_2T = {} ALL_LANGUAGES.each do |lang| BY_NAME[lang.name.downcase] = lang BY_ISO_639_1[lang.iso_639_1] = lang if lang.iso_639_1 BY_ISO_639_3[lang.iso_639_3] = lang if lang.iso_639_3 + BY_ISO_639_2B[lang.iso_639_2b] = lang if lang.iso_639_2b + BY_ISO_639_2T[lang.iso_639_2t] = lang if lang.iso_639_2t end end