Try ERPNext Try Frappe Cloud Buy Support Partners Foundation

How to get language selected in print preview

Hi all,

I want to get selected language in print preview as the example below to use it in custom print format HTML field. How can I get it?

Code Example

{% if selected_language == "en" %}							
	{{ write something }}
{% else %}						
	{{ write something else }}
{% endif %}

Thanks

3 Likes

Hi,

could you find a solution to this? I am currently having the same problem and can’t find a way to access the selected language. As the selected language is used within the template for the translation, it must be available in this scope, right?

Okay, I was able to help myself. frappe.form_dict._lang does the trick!

6 Likes

This works. Thanks you.

One problem I found is with the PDF sent via email. Seems like the backend is not aware of this item when creating the PDF. Any ideas how to workaround that?