Method: String#replace_diacritics!
- Defined in:
- lib/nuggets/i18n.rb
#replace_diacritics! ⇒ Object
call-seq:
str.replace_diacritics! => str or +nil+
Destructive version of #replace_diacritics.
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/nuggets/i18n.rb', line 126 def replace_diacritics! diacritics = ::Nuggets::I18n::DIACRITICS gsub!(/#{::Regexp.union(*diacritics.keys)}/) { |m| s = diacritics[m] # Try to adjust case: # 'Äh' => 'AEh' => 'Aeh' # # But: # 'SÖS' => 'SOES' (not 'SOeS'!) if s.length > 1 t = $'[0, 1] s[1..-1] = s[1..-1].downcase if t == t.downcase end s } end |