diff options
Diffstat (limited to 'activesupport/lib/active_support/inflector/transliterate.rb')
-rw-r--r-- | activesupport/lib/active_support/inflector/transliterate.rb | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/activesupport/lib/active_support/inflector/transliterate.rb b/activesupport/lib/active_support/inflector/transliterate.rb index a372b6d1f7..1cde417fc5 100644 --- a/activesupport/lib/active_support/inflector/transliterate.rb +++ b/activesupport/lib/active_support/inflector/transliterate.rb @@ -8,7 +8,7 @@ module ActiveSupport # Replaces non-ASCII characters with an ASCII approximation, or if none # exists, a replacement character which defaults to "?". # - # transliterate("Ærøskøbing") + # transliterate('Ærøskøbing') # # => "AEroskobing" # # Default approximations are provided for Western/Latin characters, @@ -30,33 +30,33 @@ module ActiveSupport # ö: "oe" # # # Or set them using Ruby - # I18n.backend.store_translations(:de, :i18n => { - # :transliterate => { - # :rule => { - # "ü" => "ue", - # "ö" => "oe" + # I18n.backend.store_translations(:de, i18n: { + # transliterate: { + # rule: { + # 'ü' => 'ue', + # 'ö' => 'oe' # } # } # }) # - # The value for <tt>i18n.transliterate.rule</tt> can be a simple Hash that maps - # characters to ASCII approximations as shown above, or, for more complex - # requirements, a Proc: + # The value for <tt>i18n.transliterate.rule</tt> can be a simple Hash that + # maps characters to ASCII approximations as shown above, or, for more + # complex requirements, a Proc: # - # I18n.backend.store_translations(:de, :i18n => { - # :transliterate => { - # :rule => lambda {|string| MyTransliterator.transliterate(string)} + # I18n.backend.store_translations(:de, i18n: { + # transliterate: { + # rule: ->(string) { MyTransliterator.transliterate(string) } # } # }) # # Now you can have different transliterations for each locale: # # I18n.locale = :en - # transliterate("Jürgen") + # transliterate('Jürgen') # # => "Jurgen" # # I18n.locale = :de - # transliterate("Jürgen") + # transliterate('Jürgen') # # => "Juergen" def transliterate(string, replacement = "?") I18n.transliterate(ActiveSupport::Multibyte::Unicode.normalize( @@ -64,7 +64,8 @@ module ActiveSupport :replacement => replacement) end - # Replaces special characters in a string so that it may be used as part of a 'pretty' URL. + # Replaces special characters in a string so that it may be used as part of + # a 'pretty' URL. # # class Person # def to_param |