Skip to content

Commit

Permalink
Add ru_chars to Char (#1070)
Browse files Browse the repository at this point in the history
  • Loading branch information
nikolaev-dev authored and stympy committed Nov 18, 2017
1 parent 3955325 commit b33d61a
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions lib/helpers/char.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,27 @@ def self.romanize_cyrillic(string)
}
return string.gsub(/[а-яА-ЯіїєґІЇЄҐ]/, uk_chars)
end

if Faker::Config.locale == "ru"
# Based on conventions abopted by BGN/PCGN for Russian
ru_chars = {
'а' => 'a', 'б' => 'b', 'в' => 'v', 'г' => 'h', 'д' => 'd', 'е' => 'e',
'ё' => 'ye', 'ж' => 'zh', 'з' => 'z', 'и' => 'i', 'й' => 'y', 'к' => 'k',
'л' => 'l', 'м' => 'm', 'н' => 'n', 'о' => 'o', 'п' => 'p', 'р' => 'r',
'с' => 's', 'т' => 't', 'у' => 'u', 'ф' => 'f', 'х' => 'kh', 'ц' => 'ts',
'ч' => 'ch', 'ш' => 'sh', 'щ' => 'shch', 'ы' => 'у', 'э' => 'e', 'ю' => 'yu',
'я' => 'ya',
'А' => 'a', 'Б' => 'b', 'В' => 'v', 'Г' => 'h', 'Д' => 'd', 'Е' => 'e',
'Ё' => 'ye', 'Ж' => 'zh', 'З' => 'z', 'И' => 'i', 'Й' => 'y', 'К' => 'k',
'Л' => 'l', 'М' => 'm', 'Н' => 'n', 'О' => 'o', 'П' => 'p', 'Р' => 'r',
'С' => 's', 'Т' => 't', 'У' => 'u', 'Ф' => 'f', 'Х' => 'kh', 'Ц' => 'ts',
'Ч' => 'ch', 'Ш' => 'sh', 'Щ' => 'shch', 'Ы' => 'у', 'Э' => 'e', 'Ю' => 'yu',
'Я' => 'ya',
'ь' => '', 'ъ' => '' # Ignore symbols, because its standard presentation is not allowed in URLs
}
return string.gsub(/[а-яА-Я]/, ru_chars)
end

string
end
end
Expand Down

0 comments on commit b33d61a

Please sign in to comment.