Add and fix comments, fix transliteration maps so only first character is capitalized

This commit is contained in:
Elara 2021-10-06 13:26:16 -07:00
parent 4bc6eb9d41
commit c23201e18c
3 changed files with 15 additions and 7 deletions

View File

@ -124,16 +124,23 @@ var armenianMap = []string{
func (at *ArmenianTranslit) Init() {
if !at.initComplete {
// Copy map as original will be changed
lower := armenianMap
// For every value in copied map
for i, val := range lower {
// If index is odd, skip
if i%2 == 1 {
continue
}
// Capitalize first letter
capital := strings.Title(val)
// If capital is not the same as lowercase
if capital != val {
// Add capital to map
armenianMap = append(armenianMap, capital, strings.Title(armenianMap[i+1]))
}
}
// Set init complete to true so it is not run again
at.initComplete = true
}
}

View File

@ -39,6 +39,7 @@ func (ct *ChineseTranslit) Transliterate(s string) string {
outBuf.WriteRune(char)
}
}
// If buffer contains characters
if tmpBuf.Len() > 0 {
// Convert to pinyin (without tones)
out := pinyin.LazyConvert(tmpBuf.String(), nil)

View File

@ -41,7 +41,7 @@ type Transliterator interface {
}
// Map implements Transliterator using a slice where
// every odd element is a key and every even one is a value
// every even element is a key and every odd one is a value
// which replaces the key.
type Map []string
@ -155,7 +155,7 @@ var Transliterators = map[string]Transliterator{
"Ζ", "Z",
"Η", "I",
"Ή", "I",
"Θ", "TH",
"Θ", "Th",
"Ι", "I",
"Ί", "I",
"Ϊ", "I",
@ -163,7 +163,7 @@ var Transliterators = map[string]Transliterator{
"Λ", "L",
"Μ", "M",
"Ν", "N",
"Ξ", "KS",
"Ξ", "Ks",
"Ο", "O",
"Ό", "O",
"Π", "P",
@ -174,8 +174,8 @@ var Transliterators = map[string]Transliterator{
"Ύ", "Y",
"Ϋ", "Y",
"Φ", "F",
"Χ", "CH",
"Ψ", "PS",
"Χ", "Ch",
"Ψ", "Ps",
"Ω", "O",
"Ώ", "O",
},
@ -188,8 +188,8 @@ var Transliterators = map[string]Transliterator{
"є", "je",
"і", "i",
"ї", "ji",
"Ґ", "GH",
"Є", "JE",
"Ґ", "Gh",
"Є", "Je",
"І", "I",
"Ї", "JI",
},