Moved translation attribute into toml config. Now using origmsg var for msg text.

This commit is contained in:
Patrick Connolly
2018-10-15 06:48:14 +08:00
parent 4eaa59c594
commit f32e7a9c35
4 changed files with 10 additions and 9 deletions

View File

@@ -334,17 +334,12 @@ func (gw *Gateway) handleMessage(msg config.Message, dest *bridge.Bridge) []*BrM
msg.ID = ""
if (gw.Router.GTClient != nil) && (channel.Options.Locale != "") {
attribution, ok := os.LookupEnv("GOOGLE_TRANSLATE_ATTRIBUTION")
if !(ok) {
attribution = " [translated by Google]"
}
ctx := context.Background()
client := gw.Router.GTClient
defer client.Close()
text := msg.Text
text := origmsg.Text
var results [][]string
// colons: add temp token
@@ -479,7 +474,9 @@ func (gw *Gateway) handleMessage(msg config.Message, dest *bridge.Bridge) []*BrM
text = regexp.MustCompile(`(ː)([ $])`).ReplaceAllString(text, ":$2")
text = html.UnescapeString(text)
msg.Text = text + attribution
text = text + gw.Router.General.TranslationAttribution
msg.Text = text
}
}
if res, ok := gw.Messages.Get(origmsg.ID); ok {