Created
March 8, 2017 14:41
-
-
Save yuksbg/7463b2db7de59cbce60087ca4746b28c to your computer and use it in GitHub Desktop.
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
package main | |
import "regexp" | |
import "log" | |
func toLatin(content string) string { | |
var translations = map[string]string{ | |
"а":"a", | |
"б":"b", | |
"в":"v", | |
"г":"g", | |
"д":"d", | |
"е":"e", | |
"ж":"zh", | |
"з":"z", | |
"и":"i", | |
"й":"y", | |
"к":"k", | |
"л":"l", | |
"м":"m", | |
"н":"n", | |
"о":"o", | |
"п":"p", | |
"р":"r", | |
"с":"s", | |
"т":"t", | |
"у":"u", | |
"ф":"f", | |
"х":"h", | |
"ц":"ts", | |
"ч":"ch", | |
"ш":"sh", | |
"щ":"sht", | |
"ъ":"a", | |
"ь":"y", | |
"ю":"yu", | |
"я":"ya", | |
"А":"A", | |
"Б":"B", | |
"В":"V", | |
"Г":"G", | |
"Д":"D", | |
"Е":"E", | |
"Ж":"Zh", | |
"З":"Z", | |
"И":"I", | |
"Й":"Y", | |
"К":"K", | |
"Л":"L", | |
"М":"M", | |
"Н":"N", | |
"О":"O", | |
"П":"P", | |
"Р":"R", | |
"С":"S", | |
"Т":"T", | |
"У":"U", | |
"Ф":"F", | |
"Х":"H", | |
"Ц":"Ts", | |
"Ч":"Ch", | |
"Ш":"Sh", | |
"Щ":"Sht", | |
"Ъ":"A", | |
"Ь":"Y", | |
"Ю":"Yu", | |
"Я":"Ya", | |
} | |
for k, v := range translations { | |
r, _ := regexp.Compile(k) | |
content = r.ReplaceAllString(content, v) | |
} | |
return content | |
} | |
func main() { | |
log.Println(toLatin("Тествай мееее")) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment