class I18n::Backend::Transliterator::HashTransliterator
rule.
A transliterator which accepts a Hash of characters as its translation
def add(hash)
def add(hash) hash.keys.each {|key| hash[key.to_s] = hash.delete(key).to_s} approximations.merge! hash end
def approximations
def approximations @approximations ||= {} end
def initialize(rule = nil)
def initialize(rule = nil) @rule = rule add DEFAULT_APPROXIMATIONS add rule if rule end
def transliterate(string, replacement = nil)
def transliterate(string, replacement = nil) string.gsub(/[^\x00-\x7f]/u) do |char| approximations[char] || replacement || DEFAULT_REPLACEMENT_CHAR end end