How to fetch field data in specific language in print format

Hi everyone,

I have a small cosmetic issue that is bothering me for some days now…

Inside my custom print format I’m fetching the field data of the linked customer contact person (quotation + invoice).

I’m fetching and using the data with the following command:

{% set my_company_contact = frappe.get_doc("Contact", doc.contact_person) %}
<br>
{{ my_company_contact.get_formatted('salutation') }} {{ my_company_contact.get_formatted('first_name') }} {{ my_company_contact.get_formatted('last_name') }}

And the commands are working, but due to the fact that I’m working with the system in German language, I’m expecting something translated like “Herr XXX YYY”.
Instead I’m still getting “Mr XXX YYY”.

Does someone know how I can bring the system to give me the correct german translation, which is even shown if I open up the contact directly?

Hi,

You can use the frappe._ function. For more information check this: Jinja API (frappeframework.com)

Thanks,

Divyesh Mangroliya

2 Likes

Hi @mangroliya,

thanks for the heads up and the fast solution!

{{ _(my_company_contact.get_formatted('salutation')) }}

Worked perfectly fine in this case!

Maybe as a follow up question:
Is there a logic behind which fields are getting translated automatically and for which ones I have to use the translation function?