Only do init once for Armenian transliteration

This commit is contained in:
Elara 2021-10-06 13:08:25 -07:00
parent df743cca96
commit 2a59e74a2c

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,15 +123,18 @@ var armenianMap = []string{
} }
func (at *ArmenianTranslit) Init() { func (at *ArmenianTranslit) Init() {
lower := armenianMap if !at.initComplete {
for i, val := range lower { lower := armenianMap
if i%2 == 1 { for i, val := range lower {
continue if i%2 == 1 {
} continue
capital := strings.Title(val) }
if capital != val { capital := strings.Title(val)
armenianMap = append(armenianMap, capital, strings.Title(armenianMap[i+1])) if capital != val {
armenianMap = append(armenianMap, capital, strings.Title(armenianMap[i+1]))
}
} }
at.initComplete = true
} }
} }