Translation doesn't work in website


I still have problems with translations on website part of Frappe framework, it doesn’t work because the _messages dictionnary is always empty.

Here is an easy way to reproduce it :

  • Configure ERPNext in language <> en
  • Go to login page
  • Enter bad credencials
  • Validate

Result : “Invalid Login. Try again.” is not translated but it should because __() function is used and translation is present in the translation files.
401: get_error_handler(__("Invalid Login. Try again.")),

I already entered an issue in April, but I’ve no answer for now and this bug is really critical because translations are essentials for production websites and it affects all pages with javascript, that is to say almost all.
I would be glad to fix it, but I would like to know how and when this dict must be populated ?

Here is the original github issue :

Thanks !

@rmehta, could you please help us on this issue ?


The JS is directly loaded via Jinja include frappe/login.html at develop · frappe/frappe · GitHub

There needs to be some pre-processing to append the _messages.

Or maybe just use Jinja tags in the login.js so the messages are translated on the server.


get_error_handler("{{ _("Invalid Login. Try again.") }}")

Can you check if that works?

1 Like

It works like a charm ! Thank you !
Could I considerer this way as a best practice and modify existing files ?
I will send a PR and __() function will become obsolete.

1 Like

Yeah sure! I think that is the best option. Please send the PR :slight_smile: