How do I transliterate Cyrillic symbols in string into Latin in Ruby? I can't find any docs on that. I thought there should be some standard function for that.
You can use the translit
gem:
require 'translit'
str = "Кириллица"
Translit.convert(str, :english)
#=> "Kirillica"
The most mature gem for working with Cyrillic/Russian is https://github.com/yaroslav/russian/
It also supports transliteration, alongside with many other services:
require 'russian'
# => true
Russian.translit('Транслит, english letters untouched')
# => "Translit, english letters untouched"
It also provides pluralisation, dates formatting, Rails i18n integration and many other goodies.
Disclaimer: I'm not in any sense affilated with the gem, just happy user.
There's a gem for that. I haven't tried it but it sounds promising...
https://github.com/dalibor/cyrillizer
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With