Script translations not loaded

Hi,

I try to understand why strings are not translated in footer_extension.html

The translations in the html part works well like {{ _(“Get Updates”) }}
But the translations in the javascript part don’t load.
At he beginning I have just through the function _() was missing, it is true for “sending…” but not for “added” or “Please enter email address”

$("#footer-subscribe-button").html(__("Added")) .attr("disabled", true);

Or frappe.msgprint(frappe._("Please enter email address")) which calls directly frappe popup function.

Translations are presents in csv translation file, if I replace “Get Updates” by “Please enter email address” for test purpose, the string is translated.
It seems the frappe method _() is not called because in python console get_full_dict(local.lang).get("Please enter email address") gives me the good translated string.

Thanks

https://github.com/frappe/erpnext/blob/develop/erpnext/templates/includes/footer/footer_extension.html

To translate strings on javaScript side use double _

Actually it is already done for “Added” for instance but still not translated.

https://github.com/frappe/erpnext/blob/develop/erpnext/templates/includes/footer/footer_extension.html#L23

I try to debug tonight and it seems somewhere inside build in translation mecanism.
frappe._messages dictionnary is empty, so no translations in javascript at all.

If I edit manually translate.js file and add the word in dictionnary the translation works.
frappe._messages["Added"]="My Translated String"

So how frappe._message dict is extended ? In request.js ?

@saurabh6790 Could you please explain me how translations should work ?
I have searched in the source code a long time but can’t understand how and when messages are loaded in the _messages dictionnary for javascript.

It is really important that translations system works for spreading Frappe.
You can reproduce the bug easily with ERPNext master branch : choose a language other than “en” and javascript __() doesn’t translate anything. You can try with the footer_extension.html by entering an email in “Get updates” field and validate => you 'll get “Added” instead of translated string.

Thanks in advance for your help

Hi all,

I’m still searching for the tranlation problem on the frappe website module.
Below is a new basic example (without ajax), I’ll try to be as clear as possible.
Don’t hesitate to ask if you need more information.

Let’s take the standard static “update-password.html” file, it is the web form for changing password.
I’ll try to get the message “Old Password Required.” translated.
To obtain this message just validate the empty form.

Here is my code, you can notice I use the same “Old Password Required.” string 2 times :

  • in the HTML part (jinja templating, server side) for placeholder field message
  • in the SCRIPT part for msgprint()
    That way I’m sure the message is well translated in the dictionnary.

Result : translation works in placeholder but not in the javascript msgprint().

Where to store the translations for such static example ?
No trace of translations in the page source code, neither in frappe-web.min.js, because frappe._messages={}

I 'll really appreciate detailed explanation.:slight_smile:
Thanks

Nobody can help me on this bug in website module ?
I can translate directly in html files but it is really dirty…

Thanks

Can someone help me on this point ?
Is the website module managed with the Frappe translation system ? Not yet ?
Thanks.