def transliterate(string, replacement = "?", locale: nil)
      raise ArgumentError, "Can only transliterate strings. Received #{string.class.name}" unless string.is_a?(String)

      I18n.transliterate(
        ActiveSupport::Multibyte::Unicode.tidy_bytes(string).unicode_normalize(:nfc),
        replacement: replacement,
        locale: locale
      )
    end
def transliterate(string, replacement = "?", locale: nil)
      raise ArgumentError, "Can only transliterate strings. Received #{string.class.name}" unless string.is_a?(String)

      I18n.transliterate(
        ActiveSupport::Multibyte::Unicode.tidy_bytes(string).unicode_normalize(:nfc),
        replacement: replacement,
        locale: locale
      )
    end
Replaces non-ASCII characters with an ASCII approximation, or if none
 exists, a replacement character which defaults to "?".

    transliterate('Ærøskøbing')
    # => "AEroskobing"

 Default approximations are provided for Western/Latin characters,
 e.g, "ø", "ñ", "é", "ß", etc.

 This method is I18n aware, so you can set up custom approximations for a
 locale. This can be useful, for example, to transliterate German's "ü"
 and "ö" to "ue" and "oe", or to add support for transliterating Russian
 to ASCII.

 In order to make your custom transliterations available, you must set
 them as the <tt>i18n.transliterate.rule</tt> i18n key:

   # Store the transliterations in locales/de.yml
   i18n:
     transliterate:
       rule:
         ü: "ue"
         ö: "oe"

   # Or set them using Ruby
   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:

   I18n.backend.store_translations(:de, i18n: {
     transliterate: {
       rule: ->(string) { MyTransliterator.transliterate(string) }
     }
   })

 Now you can have different transliterations for each locale:

   transliterate('Jürgen', locale: :en)
   # => "Jurgen"

   transliterate('Jürgen', locale: :de)
   # => "Juergen"