diff --git a/lib/language_list.rb b/lib/language_list.rb index 859cd5f..360198e 100644 --- a/lib/language_list.rb +++ b/lib/language_list.rb @@ -93,6 +93,7 @@ def self.find(code) BY_ISO_639_2T = {} ALL_LANGUAGES.each do |lang| BY_NAME[lang.name.downcase] = lang + BY_NAME[lang.common_name.downcase] = lang if lang.common_name 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 diff --git a/test/language_list_test.rb b/test/language_list_test.rb index ba4ae20..1987fb3 100755 --- a/test/language_list_test.rb +++ b/test/language_list_test.rb @@ -94,6 +94,15 @@ def test_find_by_name assert_equal 'English', english.name end + def test_find_by_common_name + greek = LanguageList::LanguageInfo.find_by_name('greek') + assert_equal 'el', greek.iso_639_1 + assert_equal 'ell', greek.iso_639_3 + assert_equal 'gre', greek.iso_639_2b + assert_equal 'ell', greek.iso_639_2t + assert_equal 'Greek', greek.common_name + end + def test_case_insensitive_find_by_name english = LanguageList::LanguageInfo.find_by_name('english') assert_equal 'en', english.iso_639_1