Problem:
When using Mimemail templates, themes, preprocess functions to add localized strings into the email then recipient's preferred language is not respected. This is the case when email is being triggered by another user with different language, for example an admin or cron running actions which send emails. The content is translated, but when adding strings in preprocess or templates, the strings are printed in English.
Solution:
Switch global $language to user's preferred language when running the theme function. Then switch it back to the original. Patch attached.
This patch is D6. Not sure if the problem exists in D7.
Comments
Comment #1
sgabe commentedI did some testing with your patch.
The attached patch seems to work for me but needs some more testing since overwriting the recipients user object may break something.
Comment #2
sgabe commentedSeems safer to check the initial mail address with which the user registered.
Comment #3
richsky commentedI feel like there is a problem with mail language in D7 also. Tested with core contact form.
Comment #4
tr commentedD6 is long past its end-of-life.
But #3 indicates there might be some similar problem in D7.
However, no details are given so I can't confirm.
It's possible this patch can still be useful in D7, but first I need someone to update this issue and try to confirm if the problem still exists on D7. I also need steps to reproduce the problem.