iso639 1.3.2 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 79c6956cb1fc30e1fbe6f7e308d5e4dad6594d74
4
- data.tar.gz: b4769d29896ebde606f19e1f476eba137b4dadc2
2
+ SHA256:
3
+ metadata.gz: b62781aae3b7d40d8ee8cc71491566cc8f9f20884430cef754a7c35947ac2116
4
+ data.tar.gz: 5003ec17cf125a113986d112489e0b4e266bff9daf53cfac73ef4edc160d6702
5
5
  SHA512:
6
- metadata.gz: a22991fffc0e18664b4aa36bbaaa5759165d6e160bce89a6ad5c5ba872bfb567930cbc052230ab95dca593c3cae7c77d026b1e54b4a69422838713e6fe1226d2
7
- data.tar.gz: 352ba2898d06e77ff7f16398e8a7fd937eae6ef48833fe82855c1412026e25cbdb69c4b84eccd4063b52c8a945ec6f35b6d1f24cf39b31eb6d5786c46117e4e6
6
+ metadata.gz: 44824e2797eb5e6dde70eb8ebf3ebade9cc6e25253894b07188303a368702c234a708547038e6577525afa18838a574307af080043368e705a4c8422a539fead
7
+ data.tar.gz: f24aa87607d243d766c7eb3ecf14415d329e618b451c026fa54471e6b84afb9c31c6a6c23bb317f6516be995a713c4fce87bdc1c22f4775093bee472b983e83e
@@ -0,0 +1,9 @@
1
+ # These are supported funding model platforms
2
+
3
+ github: [rmm5t]
4
+ # patreon: # Replace with a single Patreon username
5
+ # open_collective: # Replace with a single Open Collective username
6
+ # ko_fi: # Replace with a single Ko-fi username
7
+ # tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8
+ # community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9
+ custom: "https://www.paypal.me/rmm5t/5"
@@ -0,0 +1,13 @@
1
+ # Configuration for probot-no-response - https://github.com/probot/no-response
2
+
3
+ # Number of days of inactivity before an Issue is closed for lack of response
4
+ daysUntilClose: 7
5
+ # Label requiring a response
6
+ responseRequiredLabel: more-information-needed
7
+ # Comment to post when closing an Issue for lack of response. Set to `false` to disable
8
+ closeComment: >
9
+ This issue has been automatically closed because there has been no response
10
+ to our request for more information from the original author. With only the
11
+ information that is currently in the issue, we don't have enough information
12
+ to take action. Please reach out if you have or find the answers we need so
13
+ that we can investigate further.
@@ -0,0 +1,25 @@
1
+ name: CI
2
+ on:
3
+ push:
4
+ branches: [master]
5
+ pull_request:
6
+ branches: [master]
7
+
8
+ jobs:
9
+ test:
10
+ runs-on: ubuntu-latest
11
+ strategy:
12
+ matrix:
13
+ ruby: ["2.4", "2.5", "2.6", "2.7", "3.0", "3.1", "3.2", "3.3", "3.4", "4.0"]
14
+
15
+ steps:
16
+ # https://github.com/marketplace/actions/checkout
17
+ - uses: actions/checkout@v6
18
+ # https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
19
+ - name: Set up Ruby
20
+ uses: ruby/setup-ruby@v1
21
+ with:
22
+ ruby-version: ${{ matrix.ruby }}
23
+ bundler-cache: true # runs `bundle install` and caches gems automatically
24
+ - name: Run tests
25
+ run: bundle exec rake
data/CONTRIBUTING.md CHANGED
@@ -41,3 +41,8 @@ Syntax:
41
41
  * `MyClass.my_method(my_arg)` not `my_method( my_arg )` or `my_method my_arg`.
42
42
  * `a = b` not `a=b`.
43
43
  * Follow the conventions you see used in the source already.
44
+
45
+ ## Updating language data
46
+
47
+ Run `bundle exec rake data:update` to refresh the Library of Congress snapshot.
48
+ Review the diff and run `bundle exec rake` before committing.
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2012-2016 Ryan McGeary
1
+ Copyright (c) 2012-2018 Ryan McGeary
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -1,33 +1,18 @@
1
1
  # iso639
2
2
 
3
3
  [![Gem Version](http://img.shields.io/gem/v/iso639.svg)](http://badge.fury.io/rb/iso639)
4
- [![Build Status](https://travis-ci.org/rmm5t/iso639.svg?branch=master)](https://travis-ci.org/rmm5t/iso639)
5
- [![Code Climate](http://img.shields.io/codeclimate/github/rmm5t/iso639.svg)](https://codeclimate.com/github/rmm5t/iso639)
4
+ [![Build Status](https://github.com/rmm5t/iso639/workflows/CI/badge.svg)](https://github.com/rmm5t/iso639/actions?query=workflow%3ACI)
5
+ [![Maintainability](https://api.codeclimate.com/v1/badges/33044338aa8c859fbadc/maintainability)](https://codeclimate.com/github/rmm5t/iso639/maintainability)
6
6
  [![Gem Downloads](https://img.shields.io/gem/dt/iso639.svg)](https://rubygems.org/gems/iso639)
7
7
 
8
8
  The iso639 gem provides convenience methods for looking up ISO-639-1 or
9
9
  ISO-639-2 language codes by their english name, 2-char, or 3-char counterpart
10
10
 
11
11
  All data was generated from the Library of Congress's list of UTF-8
12
- [**Codes for the Representation of Names of Languages**](http://www.loc.gov/standards/iso639-2/ascii_8bits.html).
13
-
14
- ---
15
-
16
- **How You Can Help**
17
-
18
- [![Square Cash](http://img.shields.io/badge/square%20cash-$rmm5t-brightgreen.svg)][square]
19
- [![PayPal](http://img.shields.io/badge/paypal-rmm5t-blue.svg)][paypal]
20
- [![Book a Codementor session](http://img.shields.io/badge/codementor-book%20a%20session-orange.svg)][codementor]
21
-
22
- If you like this project, [buy me a coffee][paypal], or [book a session with me][codementor], or donate bitcoin: `1rmm5tv6f997JK5bLcGbRCZyVjZUPkQ2m`
23
-
24
- [square]: https://cash.me/$rmm5t/5 "Donate to rmm5t for open source!"
25
- [paypal]: https://www.paypal.me/rmm5t/5 "Donate to rmm5t for open source!"
26
- [bitcoin]: bitcoin:1rmm5tv6f997JK5bLcGbRCZyVjZUPkQ2m?amount=0.01&label=Coffee%20to%20rmm5t%20for%20Open%20Source "Buy rmm5t a coffee for open source!"
27
- [codementor]: https://www.codementor.io/rmm5t?utm_campaign=profile&utm_source=button-rmm5t&utm_medium=shields "Book a session with rmm5t on Codementor!"
28
-
29
- [![Twitter](https://img.shields.io/twitter/follow/rmm5t.svg?style=social)](https://twitter.com/rmm5t)
30
- [![Stack Overflow](https://img.shields.io/stackexchange/stackoverflow/r/8985.svg?style=social)](http://stackoverflow.com/users/8985/ryan-mcgeary)
12
+ [**Codes for the Representation of Names of Languages**](https://www.loc.gov/standards/iso639-2/ascii_8bits.html).
13
+ The bundled [data snapshot](https://www.loc.gov/standards/iso639-2/ISO-639-2_utf-8.txt)
14
+ was retrieved on 2026-09-19 and normalized to UTF-8 without a byte order mark,
15
+ with LF line endings and a final newline.
31
16
 
32
17
  ## Installation
33
18
 
@@ -113,8 +98,22 @@ Iso639["deu"].name # => "German"
113
98
  Iso639["ger"].name # => "German"
114
99
  Iso639["german"].name # => "German"
115
100
  Iso639["GeRmAn"].name # => "German"
101
+
102
+ # Lookup codes with locale suffixes
103
+ Iso639["en_US"].name # => "English"
104
+ Iso639["fr-CA"].name # => "French"
105
+ Iso639["zh-Hant-TW"].name # => "Chinese"
106
+
107
+ # Hyphenated names are matched in full before locale suffixes are ignored
108
+ Iso639["Judeo-Persian"].alpha3 # => "jpr"
109
+ Iso639["Luba-Lulua"].alpha3 # => "lua"
110
+ Iso639["bas-sorabe"].alpha3 # => "dsb"
116
111
  ```
117
112
 
118
113
  ## Versioning
119
114
 
120
115
  Semantic Versioning 2.0 as defined at <http://semver.org>.
116
+
117
+ ## License
118
+
119
+ [MIT License](https://rmm5t.mit-license.org/)
data/Rakefile CHANGED
@@ -8,3 +8,20 @@ Rake::TestTask.new do |t|
8
8
  t.libs << "lib" << "test"
9
9
  t.pattern = "test/**/*_test.rb"
10
10
  end
11
+
12
+ namespace :data do
13
+ desc "Refresh the ISO 639 snapshot from the Library of Congress"
14
+ task :update do
15
+ require "net/http"
16
+
17
+ url = URI("https://www.loc.gov/standards/iso639-2/ISO-639-2_utf-8.txt")
18
+ response = Net::HTTP.get_response(url)
19
+ abort "Download failed: HTTP #{response.code}" unless response.is_a?(Net::HTTPOK)
20
+
21
+ data = response.body.force_encoding("UTF-8")
22
+ data = data.sub(/\A\uFEFF/, "").gsub(/\r\n?/, "\n").chomp + "\n"
23
+ path = File.expand_path("lib/iso639/ISO-639-2_utf-8.txt", __dir__)
24
+ File.binwrite(path, data)
25
+ puts "Updated #{path}"
26
+ end
27
+ end
data/iso639.gemspec CHANGED
@@ -3,21 +3,29 @@ lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'iso639/version'
5
5
 
6
- Gem::Specification.new do |gem|
7
- gem.name = "iso639"
8
- gem.version = Iso639::VERSION
9
- gem.authors = ["Ryan McGeary"]
10
- gem.email = ["ryan@mcgeary.org"]
11
- gem.description = %q{ISO 639-1 and ISO 639-2 lookups by name, alpha-2 code, or alpha-3 code}
12
- gem.summary = gem.description
13
- gem.homepage = "https://github.com/rmm5t/iso639"
14
- gem.license = "MIT"
6
+ Gem::Specification.new do |spec|
7
+ username = "rmm5t"
8
+ spec.name = "iso639"
9
+ spec.version = Iso639::VERSION
10
+ spec.authors = ["Ryan McGeary"]
11
+ spec.email = ["ryan@mcgeary.org"]
12
+ spec.description = %q{ISO 639-1 and ISO 639-2 lookups by name, alpha-2 code, or alpha-3 code}
13
+ spec.summary = spec.description
14
+ spec.homepage = "https://github.com/#{username}/#{spec.name}"
15
+ spec.license = "MIT"
15
16
 
16
- gem.files = `git ls-files`.split($/)
17
- gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
18
- gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
19
- gem.require_paths = ["lib"]
17
+ spec.files = `git ls-files`.split($/)
18
+ spec.executables = spec.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
19
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
+ spec.require_paths = ["lib"]
20
21
 
21
- gem.add_development_dependency "minitest", "~> 5.0"
22
- gem.add_development_dependency "rake", "~> 10.0"
22
+ spec.metadata = {
23
+ "bug_tracker_uri" => "#{spec.homepage}/issues",
24
+ "changelog_uri" => "#{spec.homepage}/releases",
25
+ "source_code_uri" => spec.homepage,
26
+ "funding_uri" => "https://github.com/sponsors/#{username}",
27
+ }
28
+
29
+ spec.add_development_dependency "minitest", "~> 5.0"
30
+ spec.add_development_dependency "rake", "~> 13.0"
23
31
  end
@@ -1,4 +1,4 @@
1
- aar||aa|Afar|afar
1
+ aar||aa|Afar|afar
2
2
  abk||ab|Abkhazian|abkhaze
3
3
  ace|||Achinese|aceh
4
4
  ach|||Acoli|acoli
@@ -50,12 +50,12 @@ bem|||Bemba|bemba
50
50
  ben||bn|Bengali|bengali
51
51
  ber|||Berber languages|berbères, langues
52
52
  bho|||Bhojpuri|bhojpuri
53
- bih||bh|Bihari languages|langues biharis
53
+ bih|||Bihari languages|langues biharis
54
54
  bik|||Bikol|bikol
55
55
  bin|||Bini; Edo|bini; edo
56
56
  bis||bi|Bislama|bichlamar
57
57
  bla|||Siksika|blackfoot
58
- bnt|||Bantu (Other)|bantoues, autres langues
58
+ bnt|||Bantu languages|bantou, langues
59
59
  bos||bs|Bosnian|bosniaque
60
60
  bra|||Braj|braj
61
61
  bre||br|Breton|breton
@@ -87,15 +87,16 @@ chu||cu|Church Slavic; Old Slavonic; Church Slavonic; Old Bulgarian; Old Church
87
87
  chv||cv|Chuvash|tchouvache
88
88
  chy|||Cheyenne|cheyenne
89
89
  cmc|||Chamic languages|chames, langues
90
+ cnr|||Montenegrin|monténégrin
90
91
  cop|||Coptic|copte
91
92
  cor||kw|Cornish|cornique
92
93
  cos||co|Corsican|corse
93
94
  cpe|||Creoles and pidgins, English based|créoles et pidgins basés sur l'anglais
94
- cpf|||Creoles and pidgins, French-based |créoles et pidgins basés sur le français
95
- cpp|||Creoles and pidgins, Portuguese-based |créoles et pidgins basés sur le portugais
95
+ cpf|||Creoles and pidgins, French-based|créoles et pidgins basés sur le français
96
+ cpp|||Creoles and pidgins, Portuguese-based|créoles et pidgins basés sur le portugais
96
97
  cre||cr|Cree|cree
97
98
  crh|||Crimean Tatar; Crimean Turkish|tatar de Crimé
98
- crp|||Creoles and pidgins |créoles et pidgins
99
+ crp|||Creoles and pidgins|créoles et pidgins
99
100
  csb|||Kashubian|kachoube
100
101
  cus|||Cushitic languages|couchitiques, langues
101
102
  cze|ces|cs|Czech|tchèque
@@ -105,7 +106,7 @@ dar|||Dargwa|dargwa
105
106
  day|||Land Dayak languages|dayak, langues
106
107
  del|||Delaware|delaware
107
108
  den|||Slave (Athapascan)|esclave (athapascan)
108
- dgr|||Dogrib|dogrib
109
+ dgr|||Tlicho; Dogrib|tlicho; dogrib
109
110
  din|||Dinka|dinka
110
111
  div||dv|Divehi; Dhivehi; Maldivian|maldivien
111
112
  doi|||Dogri|dogri
@@ -161,7 +162,7 @@ gor|||Gorontalo|gorontalo
161
162
  got|||Gothic|gothique
162
163
  grb|||Grebo|grebo
163
164
  grc|||Greek, Ancient (to 1453)|grec ancien (jusqu'à 1453)
164
- gre|ell|el|Greek, Modern (1453-)|grec moderne (après 1453)
165
+ gre|ell|el|Modern Greek (1453-)|grec moderne (1453-)
165
166
  grn||gn|Guarani|guarani
166
167
  gsw|||Swiss German; Alemannic; Alsatian|suisse alémanique; alémanique; alsacien
167
168
  guj||gu|Gujarati|goudjrati
@@ -300,17 +301,17 @@ nai|||North American Indian languages|nord-amérindiennes, langues
300
301
  nap|||Neapolitan|napolitain
301
302
  nau||na|Nauru|nauruan
302
303
  nav||nv|Navajo; Navaho|navaho
303
- nbl||nr|Ndebele, South; South Ndebele|ndébélé du Sud
304
- nde||nd|Ndebele, North; North Ndebele|ndébélé du Nord
304
+ nbl||nr|South Ndebele|ndébélé du Sud
305
+ nde||nd|North Ndebele|ndébélé du Nord
305
306
  ndo||ng|Ndonga|ndonga
306
307
  nds|||Low German; Low Saxon; German, Low; Saxon, Low|bas allemand; bas saxon; allemand, bas; saxon, bas
307
308
  nep||ne|Nepali|népalais
308
- new|||Nepal Bhasa; Newari|nepal bhasa; newari
309
+ new|||Nepal Bhasa; Newar; Newari|nepal bhasa; néwar; newari
309
310
  nia|||Nias|nias
310
311
  nic|||Niger-Kordofanian languages|nigéro-kordofaniennes, langues
311
312
  niu|||Niuean|niué
312
- nno||nn|Norwegian Nynorsk; Nynorsk, Norwegian|norvégien nynorsk; nynorsk, norvégien
313
- nob||nb|Bokmål, Norwegian; Norwegian Bokmål|norvégien bokmål
313
+ nno||nn|Norwegian Nynorsk|norvégien nynorsk
314
+ nob||nb|Norwegian Bokmål|norvégien bokmål
314
315
  nog|||Nogai|nogaï; nogay
315
316
  non|||Norse, Old|norrois, vieux
316
317
  nor||no|Norwegian|norvégien
@@ -323,7 +324,7 @@ nym|||Nyamwezi|nyamwezi
323
324
  nyn|||Nyankole|nyankolé
324
325
  nyo|||Nyoro|nyoro
325
326
  nzi|||Nzima|nzema
326
- oci||oc|Occitan (post 1500); Provençal|occitan (après 1500); provençal
327
+ oci||oc|Occitan (post 1500)|occitan (après 1500)
327
328
  oji||oj|Ojibwa|ojibwa
328
329
  ori||or|Oriya|oriya
329
330
  orm||om|Oromo|galla
@@ -347,7 +348,7 @@ pol||pl|Polish|polonais
347
348
  pon|||Pohnpeian|pohnpei
348
349
  por||pt|Portuguese|portugais
349
350
  pra|||Prakrit languages|prâkrit, langues
350
- pro|||Provençal, Old (to 1500)|provençal ancien (jusqu'à 1500)
351
+ pro|||Provençal, Old (to 1500); Occitan, Old (to 1500)|provençal ancien (jusqu'à 1500); occitan ancien (jusqu'à 1500)
351
352
  pus||ps|Pushto; Pashto|pachto
352
353
  qaa-qtz|||Reserved for local use|réservée à l'usage local
353
354
  que||qu|Quechua|quechua
@@ -364,7 +365,7 @@ rus||ru|Russian|russe
364
365
  sad|||Sandawe|sandawe
365
366
  sag||sg|Sango|sango
366
367
  sah|||Yakut|iakoute
367
- sai|||South American Indian (Other)|indiennes d'Amérique du Sud, autres langues
368
+ sai|||South American Indian languages|sud-amérindiennes, langues
368
369
  sal|||Salishan languages|salishennes, langues
369
370
  sam|||Samaritan Aramaic|samaritain
370
371
  san||sa|Sanskrit|sanskrit
@@ -460,7 +461,7 @@ vie||vi|Vietnamese|vietnamien
460
461
  vol||vo|Volapük|volapük
461
462
  vot|||Votic|vote
462
463
  wak|||Wakashan languages|wakashanes, langues
463
- wal|||Walamo|walamo
464
+ wal|||Wolaitta; Wolaytta|wolaitta; wolaytta
464
465
  war|||Waray|waray
465
466
  was|||Washo|washo
466
467
  wel|cym|cy|Welsh|gallois
@@ -483,4 +484,4 @@ znd|||Zande languages|zandé, langues
483
484
  zul||zu|Zulu|zoulou
484
485
  zun|||Zuni|zuni
485
486
  zxx|||No linguistic content; Not applicable|pas de contenu linguistique; non applicable
486
- zza|||Zaza; Dimili; Dimli; Kirdki; Kirmanjki; Zazaki|zaza; dimili; dimli; kirdki; kirmanjki; zazaki
487
+ zza|||Zaza; Dimili; Dimli; Kirdki; Kirmanjki; Zazaki|zaza; dimili; dimli; kirdki; kirmanjki; zazaki
@@ -0,0 +1,11 @@
1
+ require "iso639/insensitive_hash"
2
+
3
+ module Iso639
4
+ class CodeHash < InsensitiveHash # :nodoc:
5
+ private
6
+
7
+ def normalize(key)
8
+ super.split(/[-_]/).first
9
+ end
10
+ end
11
+ end
@@ -11,7 +11,7 @@ module Iso639
11
11
  private
12
12
 
13
13
  def normalize(key)
14
- key.to_s.downcase.strip.split(/[-_]/).first
14
+ key.to_s.downcase.strip
15
15
  end
16
16
  end
17
17
  end
@@ -1,3 +1,3 @@
1
1
  module Iso639
2
- VERSION = "1.3.2"
2
+ VERSION = "1.4.0"
3
3
  end
data/lib/iso639.rb CHANGED
@@ -1,13 +1,14 @@
1
1
  require "iso639/version"
2
2
  require "iso639/language"
3
3
  require "iso639/insensitive_hash"
4
+ require "iso639/code_hash"
4
5
 
5
6
  # Public: Various methods useful for performing ISO-639 language code lookup
6
7
  # either given their ISO-639-1 or ISO-639-2 character code value or from human
7
8
  # input.
8
9
  #
9
10
  # Language code mappings came from
10
- # http://loc.gov/standards/iso639-2/ISO-639-2_utf-8.txt
11
+ # https://www.loc.gov/standards/iso639-2/ISO-639-2_utf-8.txt
11
12
  #
12
13
  # Examples
13
14
  #
@@ -29,9 +30,9 @@ require "iso639/insensitive_hash"
29
30
  # Iso639["German"].english_name # => "German"
30
31
  # Iso639["German"].french_name # => "allemand"
31
32
  module Iso639
32
- LanguagesByAlpha2 = InsensitiveHash.new
33
- LanguagesByAlpha3Bibliographic = LanguagesByAlpha3 = InsensitiveHash.new
34
- LanguagesByAlpha3Terminology = InsensitiveHash.new
33
+ LanguagesByAlpha2 = CodeHash.new
34
+ LanguagesByAlpha3Bibliographic = LanguagesByAlpha3 = CodeHash.new
35
+ LanguagesByAlpha3Terminology = CodeHash.new
35
36
  LanguagesByEnglishName = LanguagesByName = InsensitiveHash.new
36
37
  LanguagesByFrenchName = InsensitiveHash.new
37
38
 
@@ -59,10 +60,16 @@ module Iso639
59
60
  #
60
61
  # Returns an Iso639::Language object
61
62
  def self.[](lookup)
62
- LanguagesByAlpha2[lookup] ||
63
- LanguagesByAlpha3Bibliographic[lookup] ||
64
- LanguagesByAlpha3Terminology[lookup] ||
63
+ lookup = lookup.to_s.downcase.strip
64
+
65
+ # Prefer exact codes and complete names before ignoring locale suffixes.
66
+ LanguagesByAlpha2.fetch(lookup, nil) ||
67
+ LanguagesByAlpha3Bibliographic.fetch(lookup, nil) ||
68
+ LanguagesByAlpha3Terminology.fetch(lookup, nil) ||
65
69
  LanguagesByEnglishName[lookup] ||
66
- LanguagesByFrenchName[lookup]
70
+ LanguagesByFrenchName[lookup] ||
71
+ LanguagesByAlpha2[lookup] ||
72
+ LanguagesByAlpha3Bibliographic[lookup] ||
73
+ LanguagesByAlpha3Terminology[lookup]
67
74
  end
68
75
  end
@@ -0,0 +1,15 @@
1
+ require "test_helper"
2
+
3
+ describe Iso639::CodeHash do
4
+ it "should return results ignoring regional designators" do
5
+ hash = Iso639::CodeHash.new
6
+ hash["en_GB"] = "english"
7
+ hash["fr_CA"] = "french"
8
+
9
+ assert_equal "english", hash["en_US"]
10
+ assert_equal "french", hash["fr_FR"]
11
+ assert_equal "english", hash["en-US"]
12
+ assert_equal "french", hash["fr-FR"]
13
+ assert_equal "english", hash[" EN_us\t"]
14
+ end
15
+ end
@@ -23,14 +23,16 @@ describe Iso639::InsensitiveHash do
23
23
  assert_equal "last thing", hash["baz"]
24
24
  end
25
25
 
26
- it "should return results ignoring regional designators" do
26
+ it "should preserve hyphens and underscores in keys" do
27
27
  hash = Iso639::InsensitiveHash.new
28
- hash["en_GB"] = "english"
29
- hash["fr_CA"] = "french"
28
+ hash["Judeo-Persian"] = "jpr"
29
+ hash["Judeo-Arabic"] = "jrb"
30
+ hash["Judeo_Persian"] = "underscore"
30
31
 
31
- assert_equal "english", hash["en_US"]
32
- assert_equal "french", hash["fr_FR"]
33
- assert_equal "english", hash["en-US"]
34
- assert_equal "french", hash["fr-FR"]
32
+ assert_equal "jpr", hash[" JUDEO-PERSIAN "]
33
+ assert_equal "jrb", hash["judeo-arabic"]
34
+ assert_equal "underscore", hash["judeo_persian"]
35
+ assert_nil hash["Judeo"]
36
+ assert_nil hash["Judeo-Unknown"]
35
37
  end
36
38
  end
data/test/iso639_test.rb CHANGED
@@ -8,6 +8,10 @@ describe Iso639::LanguagesByAlpha2 do
8
8
  assert_equal "German", Iso639::LanguagesByAlpha2["de"].name
9
9
  end
10
10
 
11
+ it "should ignore regional designations" do
12
+ assert_equal "en", Iso639::LanguagesByAlpha2["en_US"].alpha2
13
+ end
14
+
11
15
  it "should return nil for unknown codes" do
12
16
  assert_nil Iso639::LanguagesByAlpha2["xx"]
13
17
  assert_nil Iso639::LanguagesByAlpha2["eng"]
@@ -23,6 +27,10 @@ describe Iso639::LanguagesByAlpha3Bibliographic do
23
27
  assert_equal "German", Iso639::LanguagesByAlpha3["ger"].name
24
28
  end
25
29
 
30
+ it "should ignore regional designations" do
31
+ assert_equal "fre", Iso639::LanguagesByAlpha3Bibliographic["fre-CA"].alpha3
32
+ end
33
+
26
34
  it "should return nil for unknown codes" do
27
35
  assert_nil Iso639::LanguagesByAlpha3["xxx"]
28
36
  assert_nil Iso639::LanguagesByAlpha3["en"]
@@ -36,6 +44,10 @@ describe Iso639::LanguagesByAlpha3Terminology do
36
44
  assert_equal "German", Iso639::LanguagesByAlpha3Terminology["DEU"].name
37
45
  end
38
46
 
47
+ it "should ignore regional designations" do
48
+ assert_equal "fre", Iso639::LanguagesByAlpha3Terminology["fra_CA"].alpha3
49
+ end
50
+
39
51
  it "should return valid languages by alpha-3 terminology code when it matches the bibliographic" do
40
52
  assert_equal "English", Iso639::LanguagesByAlpha3Terminology["eng"].name
41
53
  end
@@ -58,6 +70,15 @@ describe Iso639::LanguagesByEnglishName do
58
70
  assert_equal "Klingon", Iso639::LanguagesByName["tlhIngan-Hol"].name
59
71
  end
60
72
 
73
+ it "should resolve every English name to its language" do
74
+ Iso639::LanguagesByAlpha3.each_value do |lang|
75
+ lang.english_names.each do |name|
76
+ assert_same lang, Iso639::LanguagesByEnglishName[name],
77
+ "Expected #{name.inspect} to resolve to #{lang.alpha3}"
78
+ end
79
+ end
80
+ end
81
+
61
82
  it "should return nil for unknown codes" do
62
83
  assert_nil Iso639::LanguagesByName["xxxxxx"]
63
84
  assert_nil Iso639::LanguagesByName["en"]
@@ -71,6 +92,15 @@ describe Iso639::LanguagesByFrenchName do
71
92
  assert_equal "German", Iso639::LanguagesByFrenchName["allemand"].name
72
93
  end
73
94
 
95
+ it "should resolve every French name to its language" do
96
+ Iso639::LanguagesByAlpha3.each_value do |lang|
97
+ lang.french_names.each do |name|
98
+ assert_same lang, Iso639::LanguagesByFrenchName[name],
99
+ "Expected #{name.inspect} to resolve to #{lang.alpha3}"
100
+ end
101
+ end
102
+ end
103
+
74
104
  it "should return nil for unknown codes" do
75
105
  assert_nil Iso639::LanguagesByFrenchName["xxxxxx"]
76
106
  assert_nil Iso639::LanguagesByFrenchName["an"]
@@ -86,6 +116,81 @@ describe Iso639 do
86
116
  assert_equal "fr", Iso639["fra"].alpha2
87
117
  assert_equal "fr", Iso639["French"].alpha2
88
118
  assert_equal "fr", Iso639["français"].alpha2
119
+ assert_equal "krc", Iso639["Karachay-Balkar"].alpha3
120
+ end
121
+
122
+ it "should resolve Afar by its alpha-3 code without a byte order mark" do
123
+ assert_equal "aar", Iso639["aa"].alpha3
124
+ assert_same Iso639["aa"], Iso639["aar"]
125
+ assert_same Iso639["aa"], Iso639::LanguagesByAlpha3Terminology["aar"]
126
+ end
127
+
128
+ it "should resolve Montenegrin by code and name" do
129
+ lang = Iso639["cnr"]
130
+ refute_nil lang
131
+ assert_equal "Montenegrin", lang.name
132
+ assert_equal "monténégrin", lang.french_name
133
+ assert_nil lang.alpha2
134
+ assert_same lang, Iso639["Montenegrin"]
135
+ assert_same lang, Iso639["monténégrin"]
136
+ end
137
+
138
+ it "should resolve updated language names and aliases" do
139
+ assert_equal "Tlicho", Iso639["dgr"].name
140
+ assert_equal "dgr", Iso639["Tlicho"].alpha3
141
+ assert_equal "dgr", Iso639["Dogrib"].alpha3
142
+ assert_equal "Modern Greek (1453-)", Iso639["ell"].name
143
+ assert_equal "gre", Iso639["Modern Greek (1453-)"].alpha3
144
+ assert_equal "Wolaitta", Iso639["wal"].name
145
+ assert_equal "wal", Iso639["Wolaitta"].alpha3
146
+ assert_equal "wal", Iso639["Wolaytta"].alpha3
147
+ assert_equal "new", Iso639["Newar"].alpha3
148
+ assert_equal "new", Iso639["néwar"].alpha3
149
+ assert_equal "pro", Iso639["Occitan, Old (to 1500)"].alpha3
150
+ end
151
+
152
+ it "should retain Bihari languages without the removed alpha-2 code" do
153
+ assert_equal "Bihari languages", Iso639["bih"].name
154
+ assert_nil Iso639["bih"].alpha2
155
+ assert_nil Iso639["bh"]
156
+ assert_nil Iso639::LanguagesByAlpha2["bh"]
157
+ end
158
+
159
+ it "should return nil for names removed from the snapshot" do
160
+ assert_nil Iso639["Walamo"]
161
+ assert_nil Iso639["Provençal"]
162
+ end
163
+
164
+ it "should distinguish hyphenated language names" do
165
+ assert_equal "jpr", Iso639["Judeo-Persian"].alpha3
166
+ assert_equal "jrb", Iso639["Judeo-Arabic"].alpha3
167
+ assert_equal "lua", Iso639["Luba-Lulua"].alpha3
168
+ assert_equal "lub", Iso639["Luba-Katanga"].alpha3
169
+ assert_equal "jpr", Iso639[" JUDÉO-PERSAN\t"].alpha3
170
+ assert_equal "jrb", Iso639["judéo-arabe"].alpha3
171
+ assert_equal "lad", Iso639["judéo-espagnol"].alpha3
172
+ assert_equal "lua", Iso639["luba-lulua"].alpha3
173
+ assert_equal "inc", Iso639["indo-aryennes, langues"].alpha3
174
+ assert_equal "ine", Iso639["indo-européennes, langues"].alpha3
175
+ end
176
+
177
+ it "should prefer complete language names to locale prefixes" do
178
+ assert_equal "mkh", Iso639["Mon-Khmer languages"].alpha3
179
+ assert_equal "dsb", Iso639["bas-sorabe"].alpha3
180
+ end
181
+
182
+ it "should prefer exact codes to matching language names" do
183
+ assert_equal "gle", Iso639["Ga"].alpha3
184
+ assert_equal "gaa", Iso639::LanguagesByName["Ga"].alpha3
185
+ end
186
+
187
+ it "should return nil for incomplete or unknown hyphenated names" do
188
+ assert_nil Iso639["Judeo"]
189
+ assert_nil Iso639["Judeo-Unknown"]
190
+ assert_nil Iso639["Karachay"]
191
+ assert_nil Iso639["Karachay-Unknown"]
192
+ assert_nil Iso639["English-Unknown"]
193
+ assert_nil Iso639["English_Unknown"]
89
194
  end
90
195
 
91
196
  it "should ignore case sensitivity" do
@@ -107,5 +212,9 @@ describe Iso639 do
107
212
  assert_equal "en", Iso639["en_GB"].alpha2
108
213
  assert_equal "fr", Iso639["fr-CA"].alpha2
109
214
  assert_equal "fr", Iso639["fr-FR"].alpha2
215
+ assert_equal "en", Iso639[" ENG_us\t"].alpha2
216
+ assert_equal "fr", Iso639["fre-CA"].alpha2
217
+ assert_equal "fr", Iso639["fra_CA"].alpha2
218
+ assert_equal "zh", Iso639["zh-Hant-TW"].alpha2
110
219
  end
111
220
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iso639
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.2
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan McGeary
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2017-01-20 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: minitest
@@ -30,14 +29,14 @@ dependencies:
30
29
  requirements:
31
30
  - - "~>"
32
31
  - !ruby/object:Gem::Version
33
- version: '10.0'
32
+ version: '13.0'
34
33
  type: :development
35
34
  prerelease: false
36
35
  version_requirements: !ruby/object:Gem::Requirement
37
36
  requirements:
38
37
  - - "~>"
39
38
  - !ruby/object:Gem::Version
40
- version: '10.0'
39
+ version: '13.0'
41
40
  description: ISO 639-1 and ISO 639-2 lookups by name, alpha-2 code, or alpha-3 code
42
41
  email:
43
42
  - ryan@mcgeary.org
@@ -45,8 +44,10 @@ executables: []
45
44
  extensions: []
46
45
  extra_rdoc_files: []
47
46
  files:
47
+ - ".github/FUNDING.yml"
48
+ - ".github/no-response.yml"
49
+ - ".github/workflows/ci.yml"
48
50
  - ".gitignore"
49
- - ".travis.yml"
50
51
  - CHANGELOG.md
51
52
  - CONTRIBUTING.md
52
53
  - Gemfile
@@ -56,9 +57,11 @@ files:
56
57
  - iso639.gemspec
57
58
  - lib/iso639.rb
58
59
  - lib/iso639/ISO-639-2_utf-8.txt
60
+ - lib/iso639/code_hash.rb
59
61
  - lib/iso639/insensitive_hash.rb
60
62
  - lib/iso639/language.rb
61
63
  - lib/iso639/version.rb
64
+ - test/code_hash_test.rb
62
65
  - test/insensitive_hash_test.rb
63
66
  - test/iso639_test.rb
64
67
  - test/language_test.rb
@@ -66,8 +69,11 @@ files:
66
69
  homepage: https://github.com/rmm5t/iso639
67
70
  licenses:
68
71
  - MIT
69
- metadata: {}
70
- post_install_message:
72
+ metadata:
73
+ bug_tracker_uri: https://github.com/rmm5t/iso639/issues
74
+ changelog_uri: https://github.com/rmm5t/iso639/releases
75
+ source_code_uri: https://github.com/rmm5t/iso639
76
+ funding_uri: https://github.com/sponsors/rmm5t
71
77
  rdoc_options: []
72
78
  require_paths:
73
79
  - lib
@@ -82,12 +88,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
82
88
  - !ruby/object:Gem::Version
83
89
  version: '0'
84
90
  requirements: []
85
- rubyforge_project:
86
- rubygems_version: 2.6.8
87
- signing_key:
91
+ rubygems_version: 4.0.21
88
92
  specification_version: 4
89
93
  summary: ISO 639-1 and ISO 639-2 lookups by name, alpha-2 code, or alpha-3 code
90
94
  test_files:
95
+ - test/code_hash_test.rb
91
96
  - test/insensitive_hash_test.rb
92
97
  - test/iso639_test.rb
93
98
  - test/language_test.rb
data/.travis.yml DELETED
@@ -1,7 +0,0 @@
1
- language: ruby
2
- cache: bundler
3
- sudo: false
4
- rvm:
5
- - 2.2.6
6
- - 2.3.3
7
- - 2.4.0