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

Translations default to control panel language instead of site language #47

Closed
ellefsen opened this issue Jan 14, 2019 · 12 comments
Closed

Comments

@ellefsen
Copy link

I've looked through the source and found reference to the current site being set in the getBody() method when generating a view for the email. It seems though that the correct language is not being set. Only if I change the CP language the correct language file is applied.

Is this just in my case or should the correct language be set based on the primary site?

@putyourlightson
Copy link
Collaborator

Thanks for reporting this. Are you seeing this happening on a front-end request or in the control panel?

@ellefsen
Copy link
Author

With front-end requests and the CP the correct language is applied. When the email is sent the language falls back to "en" or whatever is set in the defaultCpLanguage general config

@putyourlightson
Copy link
Collaborator

Ok thanks, will look into fixing this soon.

@putyourlightson
Copy link
Collaborator

Another question, how are you seeing that the language is incorrent? Are you using the translate filter in your campaign email templates?

@ellefsen
Copy link
Author

Yes, I'm using the |t filter for twig to show translations. If I try to display the current language with {{ craft.app.language }} I get sv on the frontend and en in my mailbox.

@putyourlightson
Copy link
Collaborator

Are you able to test locally? Adding this one line should hopefully fix it, which we will add in the next release.

Craft::$app->language = $this->getSite()->language;

@ellefsen
Copy link
Author

It does reflect in {{ craft.app.language }} when I call it from the template, but the translations still look for values in /en/site.php rather than /sv/site.php. Perhaps it needs to be done earlier in the lifecycle?

@putyourlightson
Copy link
Collaborator

Your translated text is in the email template, correct? That is rendered just a few lines down...

$body = $view->renderTemplate($template, [

@ellefsen
Copy link
Author

Correct. It also runs through an mjml filter from superbig's plugin, but that should be irrelevant.

@putyourlightson
Copy link
Collaborator

Ok I'll do a local test and see what results I get.

@putyourlightson
Copy link
Collaborator

Just tested locally and it is working fine for me with the change I suggested applied. Can you double check your site's language is set to sv and that your translation file is set up correctly? If the issue persists then message me on slack or send an email with details to info@putyourlightson.net and I'll help with troubleshooting.

@ellefsen
Copy link
Author

Resolved as of version 1.5.8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant