diff --git a/src/plugins/plugin_exp_lang_detect.py b/src/plugins/plugin_exp_lang_detect.py
index 9a6081f5..cb397cfd 100755
--- a/src/plugins/plugin_exp_lang_detect.py
+++ b/src/plugins/plugin_exp_lang_detect.py
@@ -17,7 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
-from sat.core.i18n import _
+from sat.core.i18n import _, D_
from sat.core.log import getLogger
log = getLogger(__name__)
from sat.core import exceptions
@@ -41,12 +41,29 @@ PLUGIN_INFO = {
"description": _("""Detect and set message language when unknown""")
}
+CATEGORY = D_(u"Misc")
+NAME = u"lang_detect"
+LABEL = D_(u"language detection")
+PARAMS = """
+
+
+
+
+
+
+
+ """.format(category_name=CATEGORY,
+ name=NAME,
+ label=_(LABEL),
+ )
+
class LangDetect(object):
def __init__(self, host):
log.info(_(u"Language detection plugin initialization"))
self.host = host
+ host.memory.updateParams(PARAMS)
host.trigger.add("MessageReceived", self.MessageReceivedTrigger)
host.trigger.add("messageSend", self.MessageSendTrigger)
@@ -60,9 +77,14 @@ class LangDetect(object):
def MessageReceivedTrigger(self, client, message_elt, post_treat):
""" Check if source is linked and repeat message, else do nothing """
- post_treat.addCallback(self.addLanguage)
+
+ lang_detect = self.host.memory.getParamA(NAME, CATEGORY, profile_key=client.profile)
+ if lang_detect:
+ post_treat.addCallback(self.addLanguage)
return True
def MessageSendTrigger(self, client, data, pre_xml_treatments, post_xml_treatments):
- self.addLanguage(data)
+ lang_detect = self.host.memory.getParamA(NAME, CATEGORY, profile_key=client.profile)
+ if lang_detect:
+ self.addLanguage(data)
return True