Skip to content

Instantly share code, notes, and snippets.

@alakra
Created August 4, 2011 19:13
Show Gist options
  • Save alakra/1125975 to your computer and use it in GitHub Desktop.
Save alakra/1125975 to your computer and use it in GitHub Desktop.
translate your name to japansee
class String
JP_TRANSFORM = {
"a" => "ka",
"b" => "tu",
"c" => "mi",
"d" => "te",
"e" => "ku",
"f" => "lu",
"g" => "ji",
"h" => "ri",
"i" => "ki",
"j" => "zu",
"k" => "me",
"l" => "ta",
"m" => "rin",
"n" => "to",
"o" => "mo",
"p" => "no",
"q" => "ke",
"r" => "shi",
"s" => "ari",
"t" => "chi",
"u" => "do",
"v" => "ru",
"w" => "mei",
"x" => "na",
"y" => "fu",
"z" => "zi",
" " => " "
}
def to_japanese
translation = ''
self.downcase.gsub(/[^a-z\s]/, '').each_char do |char|
translation << JP_TRANSFORM[char.downcase]
end
translation
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment