human_languages 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.reuse/dep5 +12 -0
- data/.rubocop.yml +9 -0
- data/CHANGELOG.md +65 -0
- data/Gemfile +12 -0
- data/Gemfile.lock +48 -0
- data/LICENSES/LicenseRef-ISO639-3ToU.txt +11 -0
- data/LICENSES/MIT.txt +9 -0
- data/README.adoc +133 -0
- data/Rakefile +16 -0
- data/data/iso-639-3.tsv +7911 -0
- data/lib/languages/constants.rb +6 -0
- data/lib/languages/language.rb +62 -0
- data/lib/languages/version.rb +5 -0
- data/lib/languages.rb +85 -0
- data/sig/languages.rbs +67 -0
- metadata +63 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 631034119725af61d326b444a85929c504d264d846dd0290cf1ae62baf4f251f
|
4
|
+
data.tar.gz: bafdcaa5a045e7bfa8d99f7107b370908fcb38a558f25c2cd40d5cdf2fc1d3be
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c7b52732a22520bf41d360af3c8348049b4ab6c88e9c98acc5a43c4a258c849ba2e529f67631c266b3e537e73a510e8e6dee986998975b7b3732febaff3e7909
|
7
|
+
data.tar.gz: fa8c638cf53b4dc3c8d3b0101deaa430d9b686ed68ec574681c0b9039f73152d66bc262010565c9d35bde558253c95bf9f67c85d310ed966451fe9665d2f7b51
|
data/.reuse/dep5
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
|
2
|
+
Upstream-Name: languages
|
3
|
+
Upstream-Contact: Benno Bielmeier <git@bbenno.com>
|
4
|
+
Source: https://github.com/bbenno/languages
|
5
|
+
|
6
|
+
Files: *
|
7
|
+
Copyright: 2022 Benno Bielmeier <git@bbenno.com>
|
8
|
+
License: MIT
|
9
|
+
|
10
|
+
Files: data/*
|
11
|
+
Copyright: 2022 SIL International <iso639-3@sil.org>
|
12
|
+
License: LicenseRef-ISO639-3ToU
|
data/.rubocop.yml
ADDED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
|
+
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
7
|
+
|
8
|
+
## [Unreleased]
|
9
|
+
|
10
|
+
## [0.5.0] - 2022-06-06
|
11
|
+
|
12
|
+
### Changed
|
13
|
+
|
14
|
+
- Single language lookup via `Languages[...]` is now case insensitive
|
15
|
+
- Extend README
|
16
|
+
- Repository is no REUSE compliant
|
17
|
+
|
18
|
+
## [0.4.0] - 2022-06-04
|
19
|
+
|
20
|
+
### Added
|
21
|
+
|
22
|
+
- `Languages.names` interface, providing all reference names
|
23
|
+
- `Languages.alpha2_codes` interface, providing all ISO 639-1 codes
|
24
|
+
- `Languages.alpha3_codes` interface, providing all ISO 639-3 codes
|
25
|
+
|
26
|
+
## [0.3.0] - 2022-06-04
|
27
|
+
|
28
|
+
### Added
|
29
|
+
|
30
|
+
- `Languages.search` interface, taking String or Regex pattern
|
31
|
+
|
32
|
+
## [0.2.0] - 2022-06-04
|
33
|
+
|
34
|
+
### Added
|
35
|
+
|
36
|
+
- Make Language objects comparable
|
37
|
+
|
38
|
+
### Changed
|
39
|
+
|
40
|
+
- Equality of Language objects only depends on their `iso639-3` attribute, that is unique
|
41
|
+
|
42
|
+
## [0.1.2] - 2022-06-04
|
43
|
+
|
44
|
+
### Changed
|
45
|
+
|
46
|
+
- Extend ruby signatures
|
47
|
+
- Setting `:id` aka. `iso639-3` to `nil` is no longer possible (was never intended)
|
48
|
+
|
49
|
+
### Fix
|
50
|
+
|
51
|
+
- ruby signatures
|
52
|
+
|
53
|
+
## [0.1.1] - 2022-06-04
|
54
|
+
|
55
|
+
### Changed
|
56
|
+
|
57
|
+
- Extend doc comments for Language's private methods
|
58
|
+
|
59
|
+
### Fixes
|
60
|
+
|
61
|
+
- Language's compare method `<=>`
|
62
|
+
|
63
|
+
## [0.1.0] - 2022-06-04
|
64
|
+
|
65
|
+
- Initial release
|
data/Gemfile
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source 'https://rubygems.org'
|
4
|
+
|
5
|
+
# Specify your gem's dependencies in languages.gemspec
|
6
|
+
gemspec
|
7
|
+
|
8
|
+
gem 'minitest', '~> 5.0'
|
9
|
+
gem 'rake', '~> 13.0'
|
10
|
+
gem 'rubocop', '~> 1.21'
|
11
|
+
gem 'rubocop-minitest', '~> 0.20.0'
|
12
|
+
gem 'rubocop-rake', '~> 0.6.0'
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
languages (0.5.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
ast (2.4.2)
|
10
|
+
minitest (5.15.0)
|
11
|
+
parallel (1.22.1)
|
12
|
+
parser (3.1.2.0)
|
13
|
+
ast (~> 2.4.1)
|
14
|
+
rainbow (3.1.1)
|
15
|
+
rake (13.0.6)
|
16
|
+
regexp_parser (2.5.0)
|
17
|
+
rexml (3.2.5)
|
18
|
+
rubocop (1.30.0)
|
19
|
+
parallel (~> 1.10)
|
20
|
+
parser (>= 3.1.0.0)
|
21
|
+
rainbow (>= 2.2.2, < 4.0)
|
22
|
+
regexp_parser (>= 1.8, < 3.0)
|
23
|
+
rexml (>= 3.2.5, < 4.0)
|
24
|
+
rubocop-ast (>= 1.18.0, < 2.0)
|
25
|
+
ruby-progressbar (~> 1.7)
|
26
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
27
|
+
rubocop-ast (1.18.0)
|
28
|
+
parser (>= 3.1.1.0)
|
29
|
+
rubocop-minitest (0.20.0)
|
30
|
+
rubocop (>= 0.90, < 2.0)
|
31
|
+
rubocop-rake (0.6.0)
|
32
|
+
rubocop (~> 1.0)
|
33
|
+
ruby-progressbar (1.11.0)
|
34
|
+
unicode-display_width (2.1.0)
|
35
|
+
|
36
|
+
PLATFORMS
|
37
|
+
x86_64-linux
|
38
|
+
|
39
|
+
DEPENDENCIES
|
40
|
+
languages!
|
41
|
+
minitest (~> 5.0)
|
42
|
+
rake (~> 13.0)
|
43
|
+
rubocop (~> 1.21)
|
44
|
+
rubocop-minitest (~> 0.20.0)
|
45
|
+
rubocop-rake (~> 0.6.0)
|
46
|
+
|
47
|
+
BUNDLED WITH
|
48
|
+
2.3.7
|
@@ -0,0 +1,11 @@
|
|
1
|
+
ISO 639-3 Code Tables Terms of Use
|
2
|
+
|
3
|
+
The ISO 639-3 code set may be downloaded and incorporated into software products, web-based systems, digital devices, etc., either commercial or non-commercial, provided that:
|
4
|
+
|
5
|
+
* attribution is given www.iso639-3.sil.org as the source of the codes;
|
6
|
+
* the identifiers of the code set are not modified or extended except as may be privately agreed using the Private Use Area (range qaa to qtz), and then such extensions shall not be distributed publicly;
|
7
|
+
* the product, system, or device does not provide a means to redistribute the code set.
|
8
|
+
|
9
|
+
Expansions to the information provided by the standard (e.g., population data, names in other languages, geographic coordinates, etc.) may be made and distributed as long as such added information is clearly identified as not being part of the standard itself. The ISO 639-3 website is the only authorized distribution site for the ISO 639-3 code tables.
|
10
|
+
|
11
|
+
For any questions about whether a particular use is covered by these guidelines, contact the Registration Authority at ISO639-3@sil.org.
|
data/LICENSES/MIT.txt
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) <year> <copyright holders>
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
6
|
+
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
8
|
+
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.adoc
ADDED
@@ -0,0 +1,133 @@
|
|
1
|
+
= Languages
|
2
|
+
Benno Bielmeier
|
3
|
+
:source-language: ruby
|
4
|
+
|
5
|
+
image:https://api.reuse.software/badge/github.com/bbenno/languages[link="https://api.reuse.software/info/github.com/bbenno/languages", alt="REUSE status"]
|
6
|
+
image:https://img.shields.io/github/v/tag/bbenno/languages[GitHub tag (latest SemVer)]
|
7
|
+
|
8
|
+
image:https://img.shields.io/maintenance/yes/2022[Maintenance]
|
9
|
+
image:https://github.com/bbenno/languages/actions/workflows/main.yml/badge.svg[link="https://github.com/bbenno/languages/actions/workflows/main.yml"]
|
10
|
+
|
11
|
+
Simple, dependency-less gem providing all known human languagesfootnote:[This includes all individual languages already accounted for in ISO 639-2 as well as extinct, ancient, constructed, and historical languages.] defined in ISO 639-3
|
12
|
+
|
13
|
+
The ISO code set in link:data/[data/] is taken from the official ISO 639-3 registration authority (ISO 639-3/RA) https://iso639-3.sil.org/[SIL International].
|
14
|
+
|
15
|
+
== Installation
|
16
|
+
|
17
|
+
Add this line to your application’s Gemfile:
|
18
|
+
[source]
|
19
|
+
----
|
20
|
+
gem 'languages'
|
21
|
+
----
|
22
|
+
|
23
|
+
And then execute:
|
24
|
+
....
|
25
|
+
$ bundle install
|
26
|
+
....
|
27
|
+
|
28
|
+
Or install it yourself as:
|
29
|
+
....
|
30
|
+
$ gem install languages
|
31
|
+
....
|
32
|
+
|
33
|
+
== Usage
|
34
|
+
|
35
|
+
.Foremost, load the gem
|
36
|
+
[source]
|
37
|
+
require 'languages'
|
38
|
+
|
39
|
+
=== Library Interface
|
40
|
+
|
41
|
+
The following examples show, how to get a language by its ISO 639-1 code, ISO 639-2 code, ISO 639-3 code, or by its (English) reference name.
|
42
|
+
The codes should be passed as String or Symbol, whereby the casing in both options does not matter.
|
43
|
+
|
44
|
+
.Retrieving single languages
|
45
|
+
[source]
|
46
|
+
----
|
47
|
+
german = Languages[:de] # passing ISO 639-1 code returns the corresponding Language object
|
48
|
+
english = Languages[:eng] # also works with ISO 639-2 and ISO 639-3 codes
|
49
|
+
italian = Languages['ita'] # even if passed as String
|
50
|
+
|
51
|
+
russian = Languages['Russian'] # Languages can be retrieved via reference name, too
|
52
|
+
klingon = Languages['KLINgon'] # weird casing, but still works
|
53
|
+
|
54
|
+
invalid = Languages[:invalid] # invalid or unknown names or ISO codes returns nil
|
55
|
+
----
|
56
|
+
|
57
|
+
.Get all ISO 639-3 languages
|
58
|
+
[source]
|
59
|
+
Languages.all
|
60
|
+
|
61
|
+
.Get languages by name
|
62
|
+
[source]
|
63
|
+
----
|
64
|
+
Languages.search "^Germ"
|
65
|
+
Languages.search /\AJapan/
|
66
|
+
----
|
67
|
+
|
68
|
+
CAUTION: `Languages.search` is case-sensitive unless specified explicitly, e.g. using `/search_pattern/i`.
|
69
|
+
|
70
|
+
.Since ISO 639-3 categorizes the languages by scope and type, one can filter by them
|
71
|
+
[source]
|
72
|
+
----
|
73
|
+
# By scope
|
74
|
+
Languages.ancient
|
75
|
+
Languages.constructed
|
76
|
+
Languages.extinct
|
77
|
+
Languages.historical
|
78
|
+
Languages.living
|
79
|
+
Languages.special
|
80
|
+
|
81
|
+
# By languages types
|
82
|
+
Languages.individual_languages
|
83
|
+
Languages.macrolanguages
|
84
|
+
Languages.special_languages
|
85
|
+
----
|
86
|
+
|
87
|
+
.Further custom language selections can be implemented using `Languages.all`
|
88
|
+
[source]
|
89
|
+
Languages.all.select { |l| %w[ancient historical].include?(l.type) }
|
90
|
+
|
91
|
+
=== Data Objects
|
92
|
+
|
93
|
+
The `Language` objects have a simple read-only interface:
|
94
|
+
[source]
|
95
|
+
----
|
96
|
+
language = Language[:fr]
|
97
|
+
|
98
|
+
language.name # => French
|
99
|
+
language.alpha2 # => :fr (alias for #iso639_1)
|
100
|
+
language.alpha3 # => :fra (alias for #iso639_3)
|
101
|
+
language.alpha3_bibliographic # => :fre (alias for #iso_639_2b)
|
102
|
+
language.alpha3_terminology # => :fra (alias for #iso_639_2t)
|
103
|
+
language.type # => "living"
|
104
|
+
language.scope # => "individual"
|
105
|
+
|
106
|
+
language.extinct? # => false
|
107
|
+
language.living? # => true
|
108
|
+
language.individual_language? # => true
|
109
|
+
----
|
110
|
+
|
111
|
+
== Development
|
112
|
+
|
113
|
+
After checking out the repo, run `bin/setup` to install dependencies.
|
114
|
+
Then, run `rake test` to run the tests.
|
115
|
+
You can also run `bin/console` for an interactive prompt that allows you to experiment.
|
116
|
+
To update and override the ISO 639-3 code table stored in link:data/[`data/`] run `bin/update-data`.
|
117
|
+
|
118
|
+
To install this gem onto your local machine, run `bundle exec rake install`.
|
119
|
+
To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to https://rubygems.org[rubygems.org].
|
120
|
+
|
121
|
+
Following https://semver.org/[Semantic Versioning 2.0.0].
|
122
|
+
|
123
|
+
== Contributing
|
124
|
+
|
125
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/bbenno/languages.
|
126
|
+
|
127
|
+
== Legal
|
128
|
+
|
129
|
+
The gem is
|
130
|
+
|
131
|
+
* available as open source under the terms of the https://opensource.org/licenses/MIT[MIT License].
|
132
|
+
* https://reuse.software/[REUSE] compliant
|
133
|
+
* uses ISO 639-3 code table from http://www.iso639-3.sil.org/ under their https://iso639-3.sil.org/code_tables/download_tables#termsofuse[terms of use]
|
data/Rakefile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bundler/gem_tasks'
|
4
|
+
require 'rake/testtask'
|
5
|
+
|
6
|
+
Rake::TestTask.new(:test) do |t|
|
7
|
+
t.libs << 'test'
|
8
|
+
t.libs << 'lib'
|
9
|
+
t.test_files = FileList['test/**/test_*.rb']
|
10
|
+
end
|
11
|
+
|
12
|
+
require 'rubocop/rake_task'
|
13
|
+
|
14
|
+
RuboCop::RakeTask.new
|
15
|
+
|
16
|
+
task default: %i[test rubocop]
|