class I18n::Backend::Transliterator::HashTransliterator
Experimental RBS support (using type sampling data from the type_fusion
project).
# sig/i18n/backend/transliterator.rbs class I18n::Backend::Transliterator::HashTransliterator def transliterate: (String string, ?String replacement) -> String end
rule.
A transliterator which accepts a Hash of characters as its translation
def add(hash)
def add(hash) hash.each do |key, value| approximations[key.to_s] = value.to_s end end
def add_default_approximations
def add_default_approximations DEFAULT_APPROXIMATIONS.each do |key, value| approximations[key] = value end 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)
Experimental RBS support (using type sampling data from the type_fusion
project).
def transliterate: (String string, ?String replacement) -> String
This signature was generated using 2 samples from 1 application.
def transliterate(string, replacement = nil) replacement ||= DEFAULT_REPLACEMENT_CHAR string.gsub(/[^\x00-\x7f]/u) do |char| approximations[char] || replacement end end