Update variable names and comments for interface-based transliteration
This commit is contained in:
parent
6b94030b83
commit
c56c0ae198
@ -73,7 +73,7 @@ func initNotifRelay(dev *infinitime.Device) error {
|
||||
}
|
||||
|
||||
maps := viper.GetStringSlice("notifs.translit.use")
|
||||
translit.Maps["custom"] = translit.Map(viper.GetStringSlice("notifs.translit.custom"))
|
||||
translit.Transliterators["custom"] = translit.Map(viper.GetStringSlice("notifs.translit.custom"))
|
||||
sender = translit.Transliterate(sender, maps...)
|
||||
summary = translit.Transliterate(summary, maps...)
|
||||
body = translit.Transliterate(body, maps...)
|
||||
|
@ -171,7 +171,7 @@ func handleConnection(conn net.Conn, dev *infinitime.Device) {
|
||||
break
|
||||
}
|
||||
maps := viper.GetStringSlice("notifs.translit.use")
|
||||
translit.Maps["custom"] = translit.Map(viper.GetStringSlice("notifs.translit.custom"))
|
||||
translit.Transliterators["custom"] = translit.Map(viper.GetStringSlice("notifs.translit.custom"))
|
||||
title := translit.Transliterate(reqData.Title, maps...)
|
||||
body := translit.Transliterate(reqData.Body, maps...)
|
||||
// Send notification to watch
|
||||
|
@ -9,7 +9,7 @@ func Transliterate(s string, useMaps ...string) string {
|
||||
// Create variable to store modified string
|
||||
out := s
|
||||
// If custom map exists
|
||||
if customMap, ok := Maps["custom"]; ok {
|
||||
if customMap, ok := Transliterators["custom"]; ok {
|
||||
// Perform transliteration with it
|
||||
out = customMap.Transliterate(out)
|
||||
}
|
||||
@ -20,7 +20,7 @@ func Transliterate(s string, useMaps ...string) string {
|
||||
continue
|
||||
}
|
||||
// Get requested map
|
||||
translitMap, ok := Maps[useMap]
|
||||
translitMap, ok := Transliterators[useMap]
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
@ -47,9 +47,9 @@ func (mt Map) Transliterate(s string) string {
|
||||
return strings.NewReplacer(mt...).Replace(s)
|
||||
}
|
||||
|
||||
// Maps stores transliteration maps as slices to preserve order.
|
||||
// Some of these maps were sourced from https://codeberg.org/Freeyourgadget/Gadgetbridge
|
||||
var Maps = map[string]Transliterator{
|
||||
// Transliterators stores transliterator implementations for each supported language.
|
||||
// Some of these were sourced from https://codeberg.org/Freeyourgadget/Gadgetbridge
|
||||
var Transliterators = map[string]Transliterator{
|
||||
"eASCII": Map{
|
||||
"œ", "oe",
|
||||
"ª", "a",
|
||||
|
Loading…
Reference in New Issue
Block a user