Module: RuTranslit

Defined in:
lib/ru_translit.rb,
lib/transliteration/version.rb

Overview

Transliteration as well as De-/Retransliteration between russian cyrillic and English, German and Scientific transliterations. Accounts for context-dependent transliteration rules. Current limitations:

  • Only one word per pass (technically, it should work for multiple words, but the number of variations returned likely grows beyond manageability).

  • Everything will be downcased.

  • No distinction between the different translit variants: Just one list with all possible options gets returned.

Constant Summary collapse

VERSION =
"0.0.3"

Class Method Summary collapse

Class Method Details

.to_cyrillic(latin_term, include_softeners = false) ⇒ Object Also known as: to_cy, detransliterate

De-transliterates a single latin word to cyrillic. returns an array of possible cyrillic strings if include_softeners is true, variations including only the positioning of softeners get added to the returned array as well. considers mainly German and English transliteration variants.



18
19
20
21
# File 'lib/ru_translit.rb', line 18

def self.to_cyrillic latin_term, include_softeners=false
  latin_term = UnicodeUtils.downcase(latin_term) #generally, the regular downcase should be fine here, but doesn't hurt like this.
  Detransliterator.cyrillic_options(latin_term, include_softeners)
end

.to_latin(cyrillic_term) ⇒ Object Also known as: to_la, transliterate

Transliterates a single cyrillic word to latin. Returns an array of possible latin strings. Considers mainly English, German and scientific (mostly minus the diacritics) transliteration variants.



25
26
27
28
# File 'lib/ru_translit.rb', line 25

def self.to_latin cyrillic_term
  cyrillic_term = UnicodeUtils.downcase(cyrillic_term) #generally, the regular downcase should be fine here, but doesn't hurt like this.
  Transliterator.translit_options(cyrillic_term)
end