Compare commits

...

2 Commits

2 changed files with 22 additions and 9 deletions

View File

@ -4,7 +4,9 @@ import (
"strings" "strings"
) )
type ArmenianTranslit struct{} type ArmenianTranslit struct {
initComplete bool
}
var armenianMap = []string{ var armenianMap = []string{
"աու", "au", "աու", "au",
@ -121,6 +123,7 @@ var armenianMap = []string{
} }
func (at *ArmenianTranslit) Init() { func (at *ArmenianTranslit) Init() {
if !at.initComplete {
lower := armenianMap lower := armenianMap
for i, val := range lower { for i, val := range lower {
if i%2 == 1 { if i%2 == 1 {
@ -131,6 +134,8 @@ func (at *ArmenianTranslit) Init() {
armenianMap = append(armenianMap, capital, strings.Title(armenianMap[i+1])) armenianMap = append(armenianMap, capital, strings.Title(armenianMap[i+1]))
} }
} }
at.initComplete = true
}
} }
func (at *ArmenianTranslit) Transliterate(s string) string { func (at *ArmenianTranslit) Transliterate(s string) string {

View File

@ -39,6 +39,14 @@ func (ct *ChineseTranslit) Transliterate(s string) string {
outBuf.WriteRune(char) outBuf.WriteRune(char)
} }
} }
if tmpBuf.Len() > 0 {
// Convert to pinyin (without tones)
out := pinyin.LazyConvert(tmpBuf.String(), nil)
// Write space-separated string to output
outBuf.WriteString(strings.Join(out, " "))
// Reset temporary buffer
tmpBuf.Reset()
}
// Return output string // Return output string
return outBuf.String() return outBuf.String()
} }