Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Transliterate cyrillic symbols in string into latin in Ruby?

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.

like image 576
Gherman Avatar asked May 28 '14 09:05

Gherman


3 Answers

You can use the translit gem:

require 'translit'

str = "Кириллица"
Translit.convert(str, :english)
#=> "Kirillica"
like image 167
Patrick Oscity Avatar answered Sep 28 '22 09:09

Patrick Oscity


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.

like image 39
zverok Avatar answered Sep 28 '22 08:09

zverok


There's a gem for that. I haven't tried it but it sounds promising...

https://github.com/dalibor/cyrillizer

like image 28
SteveTurczyn Avatar answered Sep 28 '22 09:09

SteveTurczyn