feat (web-form): enabled translations for web_forms

This commit is contained in:
Shivam Mishra 2019-07-18 19:15:48 +05:30
parent 3d0455f1f7
commit 34e77d0cad
2 changed files with 6 additions and 3 deletions

View file

@ -79,7 +79,7 @@ frappe.boot = {
};
// for backward compatibility of some libs
frappe.sys_defaults = frappe.boot.sysdefaults;
frappe.boot.lang_dict = {{ lang_dict }};
frappe._messages = {{ translated_messages }};
$(".file-size").each(function() {
$(this).text(frappe.form.formatters.FileSize($(this).text()));
});

View file

@ -10,7 +10,6 @@ from frappe.website.utils import get_comment_list
from frappe.custom.doctype.customize_form.customize_form import docfield_properties
from frappe.core.doctype.file.file import get_max_file_size
from frappe.core.doctype.file.file import remove_file_by_url
from frappe.translate import get_lang_dict
from frappe.modules.utils import export_module_json, get_doc_module
from six.moves.urllib.parse import urlencode
from frappe.integrations.utils import get_payment_gateway_controller
@ -174,7 +173,11 @@ def get_context(context):
context.max_attachment_size = get_max_file_size() / 1024 / 1024
context.show_in_grid = self.show_in_grid
context.lang_dict = frappe.as_json(get_lang_dict())
self.load_translations(context)
def load_translations(self, context):
translated_messages = frappe.translate.get_dict('doctype', self.doc_type)
context.translated_messages = frappe.as_json(translated_messages)
def load_document(self, context):
'''Load document `doc` and `layout` properties for template'''