From ddda1aad1a088de2cfbd7efb7b76808589825eef Mon Sep 17 00:00:00 2001 From: Patrick Connolly Date: Mon, 15 Oct 2018 03:52:06 +0800 Subject: [PATCH] Cleaned up language checks. --- gateway/gateway.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/gateway/gateway.go b/gateway/gateway.go index fbe65f07..c8c67ca0 100644 --- a/gateway/gateway.go +++ b/gateway/gateway.go @@ -338,7 +338,6 @@ func (gw *Gateway) handleMessage(msg config.Message, dest *bridge.Bridge) []*BrM } ctx := context.Background() - lang, _ := language.Parse(channel.Options.Locale) client := gw.Router.GTClient defer client.Close() @@ -396,17 +395,18 @@ func (gw *Gateway) handleMessage(msg config.Message, dest *bridge.Bridge) []*BrM // :emoji: codepoints, ie. 💎 text = emoji.NewEmojiParser().ReplaceAllString(text, "$0") - resp, _ := client.Translate(ctx, []string{text}, lang, &translate.Options{ - Format: "html", - }) - - text = resp[0].Text channelLang, err := language.Parse(channel.Options.Locale) if err != nil { flog.Error(err) } + resp, _ := client.Translate(ctx, []string{text}, channelLang, &translate.Options{ + Format: "html", + }) + + text = resp[0].Text + if resp[0].Source != channelLang { // If the source language is the same as this channel, // just use the original text and don't add attribution