Set language for frappe.get_print()

Hi All,

We have this custom functionality where we want to save and attach the print pdf of a Doctype after it gets submitted. In doing so, we are using the frappe.get_print function passing the print_format template, the doctype, docname and using as_pdf=True to generate the file and saving it referencing to the doctype record. The thing is, it does not include language in its args so I am supposing it is getting from frappe.local.lang which I am setting with my preferred language. But still it follows the system setting language if I trigger my function in the server-side (py) event. If I trigger it in client-side (js), it uses the correct language.

Any thoughts?


I actually fixed this in our app PDF on Submit, a couple of days ago:

With this and the latest v13+ release, {{ _("Test") }} should return the correct translation and you can use {% if frappe.lang == "de" %} 🇩🇪🎉 {% endif %} for translating longer text blocks.

1 Like

Hi @rmeyer ! Thank you for this, I have tested and it worked!