I've been trying to print out invoices for users in THEIR language - but the invoices always appear in MY language (or in fact 'und').

As an example: we have added a title field to the address (customer profile) which is a taxonomy - Mr, Mrs etc. If I print out the invoice of a German user I get Mr, Mrs etc as my language is English not German - Herr, Frau etc. should in fact appear. If I masquerade as the German user I get the Herr, Frau as expected.

Perhaps Commerce Billy and maybe drupal in general "has a problem" with rendering and languages - in that at some point in the call stack the language "changes" to the current users language (or 'und') FROM that of the user whose order we are trying to print.

I've changed commerce_billy_pdf.module to get the order user's langcode (e.g. de) and pass this into the entity_view calls in commerce_billy_pdf_html (this was mentioned here: https://drupal.stackexchange.com/questions/116453/how-to-get-default-dru...
) but although the langcode is correct at this point - when e.g. the address is rendered the langcode has become und. (so this is even stranger - und is not "my" language - my language is 'en').

This can be seen in commerce_customer.module - in commerce_customer_field_formatter_view the language is und.
In fact even it's even "worse" - if I hard code the entity_view to langcode of 'de' at this point - the title still renders as Mr,Mrs - so somewhere further down the langcode actually rendered is not the one passed in at this point...

Has anyone got commerce_billy to print out in the order user's language?

Comments

jamescook created an issue. See original summary.

jamescook’s picture

Issue summary: View changes