Can any one help me to find __ (2 underscores) function for translation , and if it does not exist How it does work.
Check translate.js
frappe/translate.js at develop · frappe/frappe · GitHub[quote=“Nisma, post:1, topic:24601”]
if it does not exist How it does
[/quote]
if the translation is not present it returns the original text.
some messages contains some string that need translation like
msgprint((‘Mandatory fields required in {0}’, [(doc.parenttype
? ((frappe.meta.docfield_map[doc.parenttype][doc.parentfield].label) + ’ (‘+ __(“Table”) + ‘)’)
: __(doc.doctype))]) + ‘
- ’ + error_fields.join(’
- ') + “
});
how it converts the language
Hi,
It calls the frappe._()
function in frappe-web.min.js (frappe/public/js/frappe/translate.js)
frappe._ = function(txt, replace) {
if(!txt)
return txt;
if(typeof(txt) != "string")
return txt;
var ret = frappe._messages[txt.replace(/\n/g, "")] || txt;
if(replace && typeof(replace) === "object") {
ret = $.format(ret, replace);
}
return ret;
};
I have entered an issue because frappe._message is empty, so it doesn’t translate anything…