rubyruby-on-rails-3rails-i18ncarmen

Carmen Gem giving special characters


I am using Carmen gem to get countries and respective states.but, when I use Carmen::Country.named("Sri Lanka").subregions.collect{|p| p.name}, I am getting this array:

["Basnāhira paḷāta",
 "Madhyama paḷāta",
 "Dakuṇu paḷāta",
 "Uturu paḷāta",
 "Næ̆gĕnahira paḷāta",
 "Vayamba paḷāta",
 "Uturumæ̆da paḷāta",
 "Ūva paḷāta",
 "Sabaragamuva paḷāta"]

and after using I18n, I am getting:

["Basnahira pa?ata",
 "Daku?u pa?ata",
 "Madhyama pa?ata",
 "Nae?genahira pa?ata",
 "Sabaragamuva pa?ata",
 "Uturu pa?ata",
 "Uturumae?da pa?ata",
 "Uva pa?ata",
 "Vayamba pa?ata"]

With ? replacing a special characters.


Solution

  • transliterate changes non ascii characters to ascii characters approximations, any characters for which there are no approximations are replaced with ?. this is explained in the docs. If this is not what you want to do, you do not want to use the transliterate method.

    If you want to write your own transliteration approximations do it like so (from the docs I linked to):

    i18n:
      transliterate:
        rule:
          ü: "ue"
          ö: "oe"