Parent

I18n::Backend::Transliterator::HashTransliterator

A transliterator which accepts a Hash of characters as its translation rule.

Constants

DEFAULT_APPROXIMATIONS

Public Class Methods

new(rule = nil) click to toggle source
    # File lib/i18n/backend/transliterator.rb, line 72
72:         def initialize(rule = nil)
73:           @rule = rule
74:           add DEFAULT_APPROXIMATIONS
75:           add rule if rule
76:         end

Public Instance Methods

transliterate(string, replacement = nil) click to toggle source
    # File lib/i18n/backend/transliterator.rb, line 78
78:         def transliterate(string, replacement = nil)
79:           string.gsub(/[^\x00-\x7f]/) do |char|
80:             approximations[char] || replacement || DEFAULT_REPLACEMENT_CHAR
81:           end
82:         end

Private Instance Methods

add(hash) click to toggle source

Add transliteration rules to the approximations hash.

    # File lib/i18n/backend/transliterator.rb, line 91
91:           def add(hash)
92:             hash.keys.each {|key| hash[key.to_s] = hash.delete(key).to_s}
93:             approximations.merge! hash
94:           end
approximations() click to toggle source
    # File lib/i18n/backend/transliterator.rb, line 86
86:           def approximations
87:             @approximations ||= {}
88:           end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.