Created
March 3, 2022 13:08
-
-
Save maxp/eff5f1dc82e79daa32a777d680266d84 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
(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