Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] CreditMemo Pdf translation uses user locale instead of credit memo locale #229

Closed
diimpp opened this issue Nov 19, 2020 · 0 comments
Closed
Labels
Bug Confirmed bugs or bugfixes.

Comments

@diimpp
Copy link
Member

diimpp commented Nov 19, 2020

CreditMemo Pdf uses |trans filter, which relies on current user locale, which is admin user for admin panel.

{{ 'sylius_refund.ui.issued_at'|trans }}: {{ creditMemo.issuedAt|date('Y-m-d H:i:s') }}<br>

Solution is to specify creditMemo.localeCode in each trans filter

--- {{ 'sylius_refund.ui.buyer'|trans }}
+++ {{ 'sylius_refund.ui.buyer'|trans([], 'messages', creditMemo.localeCode) }}

Personally I'm using special macro for pdf and emails like so

 {% macro trans(message, localeCode, arguments = [], domain = 'messages') %}
     {{ message|trans(arguments, domain, localeCode) }}
 {% endmacro %}
 
 {% import _self as macro %}

 {{ macro.trans('sylius_refund.ui.buyer', creditMemo.localeCode) }}:

Example from my debug, where credit memo is in de, but my admin user locale is en. I've replaced some |trans uses with creditMemo.localeCode, so you can see the mismatch.

image

@diimpp diimpp changed the title [Bug] CreditMemo Pdf translation uses admin user locale instead of credit memo locale [Bug] CreditMemo Pdf translation uses user locale instead of credit memo locale Nov 19, 2020
@Zales0123 Zales0123 added the Bug Confirmed bugs or bugfixes. label Nov 20, 2020
GSadee added a commit that referenced this issue Jan 29, 2021
This PR was merged into the 1.0-dev branch.

Discussion
----------

issue: #229

Admin panel locale: fr_FR, pdf is printed in english (credit memo locale)
![image](https://user-images.githubusercontent.com/22825722/106150543-c0e46f80-617b-11eb-90d2-c0022ebd7914.png)


Commits
-------

668ed50 [Pdf] set translation credit memo locale
@GSadee GSadee closed this as completed Jan 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Confirmed bugs or bugfixes.
Projects
None yet
Development

No branches or pull requests

3 participants