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