Use interface to allow for more complex transliteration implementations

This commit is contained in:
2021-10-04 17:45:26 -07:00
parent 9df6531023
commit 73f16fcfef
3 changed files with 69 additions and 44 deletions

View File

@@ -73,11 +73,10 @@ func initNotifRelay(dev *infinitime.Device) error {
}
maps := viper.GetStringSlice("notifs.translit.maps.use")
translit.Maps["custom"] = viper.GetStringSlice("notifs.translit.maps.custom")
replacer := translit.NewReplacer(maps...)
sender = replacer.Replace(sender)
summary = replacer.Replace(summary)
body = replacer.Replace(body)
translit.Maps["custom"] = translit.Map(viper.GetStringSlice("notifs.translit.maps.custom"))
sender = translit.Transliterate(sender, maps...)
summary = translit.Transliterate(summary, maps...)
body = translit.Transliterate(body, maps...)
var msg string
// If summary does not exist, set message to body.