Skip to content

Instantly share code, notes, and snippets.

@maxp
Created March 3, 2022 13:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maxp/eff5f1dc82e79daa32a777d680266d84 to your computer and use it in GitHub Desktop.
Save maxp/eff5f1dc82e79daa32a777d680266d84 to your computer and use it in GitHub Desktop.
(def translit-table-ru-en
(apply array-map [\a "a"
\b "b"
\c "c"
\d "d"
\e "e"
\f "f"
\g "g"
\h "h"
\i "i"
\j "j"
\k "k"
\l "l"
\m "m"
\n "n"
\o "o"
\p "p"
\q "q"
\r "r"
\s "s"
\t "t"
\u "u"
\v "v"
\w "w"
\x "x"
\y "y"
\z "z"
\1 "1"
\2 "2"
\3 "3"
\4 "4"
\5 "5"
\6 "6"
\7 "7"
\8 "8"
\9 "9"
\0 "0"
\а "a"
\б "b"
\в "v"
\г "g"
\д "d"
\е "e"
\ё "e"
\ж "zh"
\з "z"
\и "i"
\й "j"
\к "k"
\л "l"
\м "m"
\н "n"
\о "o"
\п "p"
\р "r"
\с "s"
\т "t"
\у "u"
\ф "f"
\х "kh"
\ц "c"
\ч "ch"
\ш "sh"
\щ "shh"
\ъ ""
\ы "y"
\ь ""
\э "e"
\ю "yu"
\я "ya"
\space "-"
]))
(defn make-translit [table s]
(reduce #(str % (or (table %2) "")) "" (clojure.string/lower-case s)))
(defn make-translit-ru-en [s]
(make-translit translit-table-ru-en s))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment