Module: PROIEL::Language

Defined in:
lib/proiel/language.rb

Constant Summary collapse

SUPPORTED_LANGUAGES =
{
  # This is a subset of language codes from ISO 639-3 and Glottolog.
  ang: 'Old English (ca. 450-1100)',
  ave: 'Avestan',
  axm: 'Middle Armenian',
  chu: 'Church Slavic',
  cms: 'Messapic',
  cnx: 'Middle Cornish',
  dum: 'Middle Dutch',
  enm: 'Middle English',
  frk: 'Old Frankish',
  frm: 'Middle French',
  fro: 'Old French (842-ca. 1400)',
  ghc: 'Hiberno-Scottish Gaelic',
  gmh: 'Middle High German',
  gml: 'Middle Low German',
  gmy: 'Mycenaean Greek',
  goh: 'Old High German (ca. 750-1050)',
  got: 'Gothic',
  grc: 'Ancient Greek (to 1453)',
  hit: 'Hittite',
  hlu: 'Hieroglyphic Luwian',
  htx: 'Middle Hittite',
  lat: 'Latin',
  lng: 'Langobardic',
  mga: 'Middle Irish (10-12th century)',
  non: 'Old Norse',
  nrp: 'North Picene',
  obt: 'Old Breton',
  oco: 'Old Cornish',
  odt: 'Old Dutch-Old Frankish',
  ofs: 'Old Frisian',
  oht: 'Old Hittite',
  olt: 'Old Lithuanian',
  orv: 'Old Russian',
  osc: 'Oscan',
  osp: 'Old Spanish',
  osx: 'Old Saxon',
  owl: 'Old-Middle Welsh',
  peo: 'Old Persian (ca. 600-400 B.C.)',
  pka: 'Ardhamāgadhī Prākrit',
  pmh: 'Maharastri Prakrit',
  por: 'Portuguese',
  pro: 'Old Provençal',
  psu: 'Sauraseni Prakrit',
  rus: 'Russian',
  san: 'Sanskrit',
  sga: 'Early Irish',
  sog: 'Sogdian',
  spa: 'Spanish',
  spx: 'South Picene',
  txb: 'Tokharian B',
  txh: 'Thracian',
  wlm: 'Middle Welsh',
  xbm: 'Middle Breton',
  xcb: 'Cumbric',
  xce: 'Celtiberian',
  xcg: 'Cisalpine Gaulish',
  xcl: 'Classical Armenian',
  xum: 'Umbrian',
  xve: 'Venetic',
}.freeze

Class Method Summary collapse

Class Method Details

.get_display_name(language_tag) ⇒ String

Returns the display name for a language.

Examples:

get_display_name(:lat)         # => "Latin"

Parameters:

  • language_tag (String, Symbol)

    language tag of language

Returns:

  • (String)

Raises:

  • (ArgumentError)


94
95
96
97
98
99
# File 'lib/proiel/language.rb', line 94

def self.get_display_name(language_tag)
  raise ArgumentError unless language_tag.is_a?(Symbol) or language_tag.is_a?(String)
  raise ArgumentError, 'unsupported language' unless language_supported?(language_tag)

  SUPPORTED_LANGUAGES[language_tag.to_sym]
end

.language_supported?(language_tag) ⇒ Boolean

Checks if a language is supported.

Examples:

language_supported?(:lat)      # => true
language_supported?('grc')     # => true

Parameters:

  • language_tag (String, Symbol)

    language tag of language to check

Returns:

  • (Boolean)

Raises:

  • (ArgumentError)


80
81
82
83
84
# File 'lib/proiel/language.rb', line 80

def self.language_supported?(language_tag)
  raise ArgumentError unless language_tag.is_a?(Symbol) or language_tag.is_a?(String)

  SUPPORTED_LANGUAGES.key?(language_tag.to_sym)
end

.supported_language_tagsArray<Symbol>

Returns tag of all supported languages

Returns:

  • (Array<Symbol>)


104
105
106
# File 'lib/proiel/language.rb', line 104

def self.supported_language_tags
  SUPPORTED_LANGUAGES.keys
end