Allowed translation attribution text to be customized.

This commit is contained in:
Patrick Connolly
2018-10-11 14:16:23 +08:00
parent ee7d9c8fb8
commit 49f2e77f84

View File

@@ -275,6 +275,12 @@ func (gw *Gateway) handleMessage(msg config.Message, dest *bridge.Bridge) []*BrM
msg.ID = ""
credsEnc, ok := os.LookupEnv("GOOGLE_APPLICATION_CREDENTIALS_BASE64")
if ok && channel.Options.Locale != "" {
attribution, ok := os.LookupEnv("GOOGLE_TRANSLATE_ATTRIBUTION")
if !(ok) {
attribution = " [translated by Google]"
}
ctx := context.Background()
lang, _ := language.Parse(channel.Options.Locale)
@@ -317,7 +323,7 @@ func (gw *Gateway) handleMessage(msg config.Message, dest *bridge.Bridge) []*BrM
text = strip.StripTags(text)
text = html.UnescapeString(text)
msg.Text = text + " [translated by Google]"
msg.Text = text + attribution
}
}
if res, ok := gw.Messages.Get(origmsg.ID); ok {