Module: Dpl::Transliterate

Included in:
Github
Defined in:
lib/dpl/helper/transliterate.rb

Constant Summary collapse

APPROXIMATIONS =
YAML.load(File.read(File.expand_path('../../../config/transliterate.yml', __dir__)))

Instance Method Summary collapse

Instance Method Details

#transliterate(string, replacement = '.') ⇒ Object



7
8
9
10
11
# File 'lib/dpl/helper/transliterate.rb', line 7

def transliterate(string, replacement = '.')
  string.gsub(/[^\x00-\x7f]/u) do |char|
    APPROXIMATIONS[char] || replacement
  end
end