diff --git a/frappe/__init__.py b/frappe/__init__.py
index 931bcccb6e..399ea2f21d 100644
--- a/frappe/__init__.py
+++ b/frappe/__init__.py
@@ -45,6 +45,7 @@ class _dict(dict):
def _(msg, lang=None):
"""Returns translated string in current lang, if exists."""
from frappe.translate import get_full_dict
+ from frappe.utils import strip_html_tags, is_html
if not hasattr(local, 'lang'):
local.lang = lang or 'en'
@@ -52,11 +53,16 @@ def _(msg, lang=None):
if not lang:
lang = local.lang
+ non_translated_msg = msg
+
+ if is_html(msg):
+ msg = strip_html_tags(msg)
+
# msg should always be unicode
msg = as_unicode(msg).strip()
# return lang_full_dict according to lang passed parameter
- return get_full_dict(lang).get(msg) or msg
+ return get_full_dict(lang).get(msg) or non_translated_msg
def as_unicode(text, encoding='utf-8'):
'''Convert to unicode if required'''
diff --git a/frappe/contacts/doctype/address/address.json b/frappe/contacts/doctype/address/address.json
index de6ceaa523..2947af03ec 100644
--- a/frappe/contacts/doctype/address/address.json
+++ b/frappe/contacts/doctype/address/address.json
@@ -660,7 +660,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
- "modified": "2018-11-27 17:57:21.913972",
+ "modified": "2018-11-27 17:57:22.913973",
"modified_by": "Administrator",
"module": "Contacts",
"name": "Address",
@@ -773,4 +773,4 @@
"track_changes": 0,
"track_seen": 0,
"track_views": 0
-}
\ No newline at end of file
+}
diff --git a/frappe/core/doctype/report/test_report.py b/frappe/core/doctype/report/test_report.py
index a8b756804e..258734743f 100644
--- a/frappe/core/doctype/report/test_report.py
+++ b/frappe/core/doctype/report/test_report.py
@@ -29,7 +29,7 @@ class TestReport(unittest.TestCase):
self.assertTrue('User' in [d[0] for d in data])
def test_report_permisisons(self):
- frappe.db.sql("""delete from `tabHas Role` where parent = %s
+ frappe.db.sql("""delete from `tabHas Role` where parent = %s
and role = 'Test Has Role'""", frappe.session.user, auto_commit=1)
if not frappe.db.exists('Role', 'Test Has Role'):
@@ -61,6 +61,7 @@ class TestReport(unittest.TestCase):
with open(os.path.join(os.path.dirname(__file__), 'user_activity_report_without_sort.json'), 'r') as f:
frappe.get_doc(json.loads(f.read())).insert()
+ report = frappe.get_doc('Report', 'User Activity Report Without Sort')
columns, data = report.get_data()
self.assertEqual(columns[0].get('label'), 'ID')
diff --git a/frappe/core/doctype/translation/test_translation.py b/frappe/core/doctype/translation/test_translation.py
index e54a8868fd..cfca3b53a4 100644
--- a/frappe/core/doctype/translation/test_translation.py
+++ b/frappe/core/doctype/translation/test_translation.py
@@ -57,6 +57,37 @@ class TestTranslation(unittest.TestCase):
frappe.local.lang_full_dict=None
self.assertTrue(_(data[1][0]), data[1][1])
+ def test_html_content_data_translation(self):
+ source = """
+ MacBook Air lasts up to an incredible 12 hours between charges. So from your morning coffee to
+ your evening commute, you can work unplugged. When it’s time to kick back and relax,
+ you can get up to 12 hours of iTunes movie playback. And with up to 30 days of standby time,
+ you can go away for weeks and pick up where you left off.Whatever the task,
+ fifth-generation Intel Core i5 and i7 processors with Intel HD Graphics 6000 are up to it.
+ """
+
+ target = """
+ MacBook Air dura hasta 12 horas increíbles entre cargas. Por lo tanto,
+ desde el café de la mañana hasta el viaje nocturno, puede trabajar desconectado.
+ Cuando es hora de descansar y relajarse, puede obtener hasta 12 horas de reproducción de películas de iTunes.
+ Y con hasta 30 días de tiempo de espera, puede irse por semanas y continuar donde lo dejó. Sea cual sea la tarea,
+ los procesadores Intel Core i5 e i7 de quinta generación con Intel HD Graphics 6000 son capaces de hacerlo.
+ """
+
+ create_translation('es', [source, target])
+
+ source = """
+ MacBook Air lasts up to an incredible 12 hours between charges. So from your morning coffee to
+ your evening commute, you can work unplugged. When it’s time to kick back and relax,
+ you can get up to 12 hours of iTunes movie playback. And with up to 30 days of standby time,
+ you can go away for weeks and pick up where you left off.Whatever the task,
+ fifth-generation Intel Core i5 and i7 processors with Intel HD Graphics 6000 are up to it.
+ """
+
+ self.assertTrue(_(source), target)
+
def get_translation_data():
html_source_data = """
Test Data"""
diff --git a/frappe/core/doctype/translation/translation.py b/frappe/core/doctype/translation/translation.py
index f69ab7c6de..88a8302e18 100644
--- a/frappe/core/doctype/translation/translation.py
+++ b/frappe/core/doctype/translation/translation.py
@@ -6,8 +6,16 @@ from __future__ import unicode_literals
import frappe
from frappe.model.document import Document
from frappe.translate import clear_cache
+from frappe.utils import strip_html_tags, is_html
class Translation(Document):
+ def validate(self):
+ if is_html(self.source_name):
+ self.remove_html_from_source()
+
+ def remove_html_from_source(self):
+ self.source_name = strip_html_tags(self.source_name).strip()
+
def on_update(self):
clear_cache()
diff --git a/frappe/core/page/desktop/desktop.js b/frappe/core/page/desktop/desktop.js
index eb6e772c35..24dd0c3b4e 100644
--- a/frappe/core/page/desktop/desktop.js
+++ b/frappe/core/page/desktop/desktop.js
@@ -323,7 +323,7 @@ $.extend(frappe.desktop, {
// if module found
if(module._id.indexOf('/')===-1 && !module._report) {
- var notifier = $(".module-count-" + module._id);
+ var notifier = $(".module-count-" + frappe.scrub(module._id));
if(notifier.length) {
notifier.toggle(sum ? true : false);
var circle = notifier.find(".circle-text");
diff --git a/frappe/core/page/desktop/desktop_module_icon.html b/frappe/core/page/desktop/desktop_module_icon.html
index f2681944f7..3e9a451eec 100644
--- a/frappe/core/page/desktop/desktop_module_icon.html
+++ b/frappe/core/page/desktop/desktop_module_icon.html
@@ -2,7 +2,7 @@
data-name="{{ module_name }}" data-link="{{ link }}" title="{{ _label }}">
{{ app_icon }}