Fix chinese transliteration when chinese characters are not followed by non-chinese characters

This commit is contained in:
Elara 2021-10-06 13:15:49 -07:00
parent a4598269e5
commit e70c9f4d7c

View File

@ -39,6 +39,14 @@ func (ct *ChineseTranslit) Transliterate(s string) string {
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 outBuf.String()
}