Created
October 22, 2015 11:17
-
-
Save shvelo/7c06d0e6f6e738650f36 to your computer and use it in GitHub Desktop.
KA -> EN Translit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: utf-8 | |
def translit text | |
out = text | |
translit_compound_from = "ჩჭღძშჟ".split "" | |
translit_compound_to = "chchghdzshzh".scan /../ | |
translit_single_from = "ქწერტთყუიოპასდფგჰჯკლზხცვბნმ".split "" | |
translit_single_to = "qwerttyuiopasdpghjklzxcvbnm".split "" | |
translit_compound_from.each_index do |i| | |
out = out.gsub(translit_compound_from[i], translit_compound_to[i]) | |
end | |
translit_single_from.each_index do |i| | |
out = out.gsub(translit_single_from[i], translit_single_to[i]) | |
end | |
out | |
end | |
puts translit ARGV[0] if ARGV[0] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment