Skip to content

Instantly share code, notes, and snippets.

@yuksbg
Created March 8, 2017 14:41
Show Gist options
  • Save yuksbg/7463b2db7de59cbce60087ca4746b28c to your computer and use it in GitHub Desktop.
Save yuksbg/7463b2db7de59cbce60087ca4746b28c to your computer and use it in GitHub Desktop.
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