Invoice pdf generation not in proper language
Summary (*)
We are using a store with 3 store views, each store view a different language. Everything is ok on frontend, proper languages are displayed. The problem is on the backend when we are generating the invoice pdf, (also shipping) the generated pdf is in the language of the admin logged in user. It is not taking in consideration the language of the store view where the order was placed. (If i select the desired language from backend for the logged in admin user the invoice pdf is generated in the atlanguage, but from what i am aware it should be translated to the store view language)
Preconditions (*)
- Magento 2.2.x & 2.3.x
Steps to reproduce (*)
- Place order(on ENG store view)
- Change locale of admin for any language (Danish in my case)
- Go to the order and invoice
- Download invoice PDF
Expected result (*)
Generated PDF is in the language of the store view where the order was placed like in email

Actual result (*)
Generated PDF is in the language of the admin logged in user

The emulation on the invoice pdf is set:
Magento\Sales\Model\Order\Pdf\Invoice
Lines :130, 131
$this->_localeResolver->emulate($invoice->getStoreId());
$this->_storeManager->setCurrentStore($invoice->getStoreId());
echo $this->_localeResolver->getLocale(); <-- The proper locale is returned, but nothing gets translated: Ex: __('Invoice # ') -> is still english Invoice instead of the proper language translation
-> On the frontend proper language translation is returned
It this a bug, or some different setup needs to be done for backend translations,
Thanks, Szabi
Hi guys,
Any update on this?
Thanks
Same happens on the latest 2.0.5 version, they are not translated. (This functionality worked well on magento 1). Any feedback would be appreciated.
Best regards
Meanwhile made a fix for it, pull request was submitted.
Hi @ksz2013 , thanks for reporting this issue and making PR. Please see comments in your PR and only after your changes we can start to process it.
According to contributor guide, tickets without response for two weeks should be closed. Please feel free to reopen if it's needed.
i just check on magento 2.1.2 and i have the same issue is there a update for this ticket ?
i am also having this issue in 2.1.2
+1
still a problem in v2.1.3
Update: here's a workaround that requires nothing but an entry into DI:
<type name="\Magento\Framework\Locale\ResolverInterface">
<plugin name="mage_localeresolver_reload" type="Magento\Framework\Translate\Locale\Resolver\Plugin" sortOrder="1" disabled="false"/>
</type>
Hi @BlitzInternet, your workaround works, except for the invoice head like: Order #, Order Date: or Invoice #. Any ideas how to fix this? Should the lines be added at the bottom or at the top of the di.xml? Does this change anything? Best regards.
This is because of a strange issue in the translation. In the PDF they don't use the string Order #, but Order #(SPACE) (there is an extra space at the end). The same goes for Invoice # and Shipment # . For example:
"Order # ","Bestelling # "
"Invoice # ","Factuur # "
"Shipment # ","Verzending # "
@BlitzInternet : are there any known side-effects of this workaround? It seems like something is manipulated on a global scale now to address a very specific issue.
@kanduvisla we haven't experienced any up to now (in 2.1.4)
https://github.com/magento/magento2/issues/4409#issuecomment-276654512
in which di.xml?
@BlitzInternet Can you please mention in which di.xml we need to add that code?
You can add this code in following file. vendor/magento/module-sales/etc/di.xml
<type name="\Magento\Framework\Locale\ResolverInterface">
<plugin name="mage_localeresolver_reload" type="Magento\Framework\Translate\Locale\Resolver\Plugin" sortOrder="1" disabled="false"/>
</type>
Hi, i have this issue in 2.2.6.
Hi, i have this issue in 2.2.6.
try this
<plugin name="mage_localeresolver_reload" type="Magento\Framework\Translate\Locale\Resolver\Plugin" sortOrder="1" disabled="false"/>
haha magento still hasn't fixed this issue after 3 years :)
I confirmed there is still issue with translation in Magento 2.2.9