GitXplorerGitXplorer
b

languages

public
5 stars
3 forks
2 issues

Commits

List of commits on branch master.
Unverified
9684fce543d8bbb9a9c22ca262963e4736bbc7ae

build(deps): bump rubocop from 1.69.2 to 1.70.0

ddependabot[bot] committed 6 days ago
Unverified
87deffb16e52afe02b3e8319729c81ee01210cf7

build(deps): bump rubocop from 1.69.1 to 1.69.2

ddependabot[bot] committed a month ago
Unverified
88d29aa356aa5dcb0b18ec481297b143ca7ab068

build(deps): bump minitest from 5.25.2 to 5.25.4

ddependabot[bot] committed a month ago
Unverified
6c55daa6e584a85b274755dfc6e7049289bfad7b

build(deps): bump rubocop from 1.69.0 to 1.69.1

ddependabot[bot] committed a month ago
Unverified
3579f388b454b2611b0f9bdbd63c4b2e957d3505

build(deps): bump rubocop from 1.68.0 to 1.69.0

ddependabot[bot] committed 2 months ago
Unverified
5592b1f71f0463ee1622db24fd7473e27515f08c

build(deps): bump minitest from 5.25.1 to 5.25.2

ddependabot[bot] committed 2 months ago

README

The README file for this repository.

= Languages Benno Bielmeier :source-language: ruby

image:https://api.reuse.software/badge/github.com/bbenno/languages[link="https://api.reuse.software/info/github.com/bbenno/languages", alt="REUSE status"] image:https://badge.fury.io/rb/human_languages.svg["Gem Version", link="https://badge.fury.io/rb/human_languages"]

image:https://img.shields.io/maintenance/yes/2024[Maintenance] image:https://github.com/bbenno/languages/actions/workflows/main.yml/badge.svg[link="https://github.com/bbenno/languages/actions/workflows/main.yml"]

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, constructed, and historical languages.] defined in ISO 639-3

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].

== Installation

Add this line to your application’s Gemfile: [source]

gem 'human_languages'

And then execute: .... $ bundle install ....

Or install it yourself as: .... $ gem install human_languages ....

== Usage

.Foremost, load the gem [source] require 'languages'

=== Library Interface

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. The codes should be passed as String or Symbol, whereby the casing in both options does not matter.

.Retrieving single languages [source]

german = Languages[:de] # passing ISO 639-1 code returns the corresponding Language object english = Languages[:eng] # also works with ISO 639-2 and ISO 639-3 codes italian = Languages['ita'] # even if passed as String

russian = Languages['Russian'] # Languages can be retrieved via reference name, too klingon = Languages['KLINgon'] # weird casing, but still works

invalid = Languages[:invalid] # invalid or unknown names or ISO codes returns nil

.Get all ISO 639-3 languages [source] Languages.all

.Get languages by name (regexp search) [source]

Languages.search /Germ/i Languages.search /\AJapan/

[CAUTION]

Searching languages by name is only allowed via Regexp that has been prepared and validated (if it comes from a untrusted user) in terms of case sensitivity and security / timeout. The support of passing search pattern of type String has been removed in v0.9.0. See https://github.com/bbenno/languages/pull/123[#123] for more details.

.Since ISO 639-3 categorizes the languages by scope and type, one can filter by them [source]

By scope

Languages.constructed Languages.extinct Languages.historical Languages.living Languages.special

By languages types

Languages.individual_languages Languages.macrolanguages Languages.special_languages

.Further custom language selections can be implemented using Languages.all [source] Languages.all.select { |l| %w[extinct historical].include?(l.type) }

=== Data Objects

The Language objects have a simple read-only interface:

[source]

language = Language[:fr]

language.name # => French language.alpha2 # => :fr (alias for #iso639_1) language.alpha3 # => :fra (alias for #iso639_3) language.alpha3_bibliographic # => :fre (alias for #iso_639_2b) language.alpha3_terminology # => :fra (alias for #iso_639_2t) language.type # => :living language.scope # => :individual

language.extinct? # => false language.living? # => true language.individual_language? # => true

Some languages of scope individual have a reference to their macrolanguage (scope `macrolanguage) that they belong to. More information on macrolanguages can be found https://iso639-3.sil.org/about/scope#Macrolanguages[here].

[source]

language = Language[:wuu] language.individual_language? # => true

macrolanguage = language.macrolanguage

macrolanguage.alpha3 # => "zho" macrolanguage.name # => "Chinese" macrolanguage.scope # => :macrolanguage macrolanguage.macrolanguage # => nil

== Related Gems and Differences

Why to build another gem for ISO 639?

.Overview [%header,cols="2,1,2,2,3"] |=== |Gem |ISO 639-1/-2 |ISO 639-3 |Translations |Data Storage

|https://rubygems.org/gems/iso639[iso639] |✅ |❌ |French |Collection of Hashes

|https://rubygems.org/gems/iso-639[iso-639] |✅ |❌ |French |Array of Arrays

|https://rubygems.org/gems/iso-639-data[iso-639-data] |✅ |(✅) only scope individual |French for ISO 639-2 |Hash of Hashes

|https://rubygems.org/gems/language_list[language_list] |✅

(✅) only scope individual
Array of Language-Objects

|https://rubygems.org/gems/human_languages[human_languages] |✅

Array of Language-Objects
===

== Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake test to run the tests. You can also run bin/console for an interactive prompt that allows you to experiment. To update and override the ISO 639-3 code table stored in link:data/[data/] run bin/update-data.

To install this gem onto your local machine, run bundle exec rake install. 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].

Following https://semver.org/[Semantic Versioning 2.0.0].

== Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/bbenno/languages.

== Legal

The gem is