Module: RailsI18n::Transliteration::Russian
- Defined in:
- lib/rails_i18n/transliteration.rb
Overview
© Yaroslav Markin, Julian “julik” Tarkhanov and Co github.com/yaroslav/russian/blob/master/lib/russian/transliteration.rb
Class Method Summary collapse
Class Method Details
.rule ⇒ Object
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/rails_i18n/transliteration.rb', line 112 def rule lambda do |string| next '' unless string chars = string.scan(%r{#{multi_keys.join '|'}|\w|.}) result = +"" chars.each_with_index do |char, index| if upper.has_key?(char) && lower.has_key?(chars[index+1]) # combined case result << upper[char].downcase.capitalize elsif upper.has_key?(char) result << upper[char] elsif lower.has_key?(char) result << lower[char] else result << char end end result end end |