Fix chinese transliteration when chinese characters are not followed by non-chinese characters
This commit is contained in:
parent
2a59e74a2c
commit
4bc6eb9d41
@ -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()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user