Project

iso-codes

0.0
Low commit activity in last 3 years
No release in over a year
A database of ISO language codes and ISO script codes for Ruby.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
>= 0
>= 0
 Project Readme

iso-codes

A comprehensive database of ISO language codes and ISO script codes for Ruby.

Installation

gem install iso-codes

Usage

Language codes can be looked up using find_language:

require 'iso_codes'

language = ISOCodes.find_language('lav')
# ISO 639-3 reference name
language.reference_name
# ISO 639-3 identifier
language.identifier
# ISO 639-1 (alpha-2) identifier
language.alpha2
# ISO 639-2 (alpha-3) identifiers
language.alpha3_bibliographic
language.alpha3_terminology

Macrolanguages

ISO 639-3 defines language identifiers that covers a set of other language identifiers. For example, the identifier lav for Latvian corresponds to lvs for Standard Latvian and ltg for Latgalian. These identifiers are called macrolanguages and can be looked up in the same way as other language codes:

language = ISOCodes.find_language('lav')
language.reference_name
# => "Latvian"
language.class
# => ISOCodes::Macrolanguage
language.alpha3_bibliographic
# => "lav"
language.alpha2
# => "lv"

The individual languages covered by the identifier can be listed:

language.individual_languages.map { |l| l.identifier }
# => ["ltg", "lvs"]

For an individual language the macrolanguage, if any, can be found.

language = ISOCodes.find_language('ltg')
language.class
# => ISOCodes::IndividualLanguage
language.macrolanguage.identifier
# => "lav"

License

MIT

Copyright

Copyright (c) 2010-2021 Marius L. Jøhndal.