Whilst trying to get my registration messages to appear in alternative languages, I've noticed a potential issue with the _user_mail_text function.
It appears that if a variable if found that contains a mail template (which seem to created as part of the installation), then the output is never run through the t() function, so cannot be translated....
Would it not be better to replace:
return strtr($admin_setting, $variables);
with
return t($admin_setting, $variables, $langcode);
Or better still, store the langcode as part of the variable so the correct translated variable could be retrieved.
e.g. 'user_mail_'. $key.'_'.$langcode
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | user_mail_text_translation-894936-4.patch | 579 bytes | Jānis Bebrītis |
Comments
Comment #1
dddave commentedThe translation of mail text is very flawed in D6. Those modules try to circumvent these problems:
http://drupal.org/project/mail_edit
http://drupal.org/project/reglang
If I remember correctly this problem is solved for D7. Setting this to duplicate because this is definitely a known problem. Sorry for not providing a link to another issue but I know they are out there. ;)
Comment #2
dmoore commentedGreat thanks - these modules have solved my problem.
Comment #3
theex commentedThis problem doesn't seem to be solved in drupal 7.8
And mail_edit doesn't solve my problem, it seems to be buggy at the moment.
Problem:
When mail template are saved they go into variables table in db.
When drupal_mail is called for a new registration _user_mail_text function is called and $text=$admin_setting;
No translation through t() is done in this case.
This change works for me (I know, it's not a good things to change core). replace (false) is a param that come from admin interface for disable token replace in mail.
Usually is true.
Hope this helps.
Sorry for my english
Comment #4
fenda commentedThis issue is still present in D7 core. I apologize if this is not classed as major, but I cannot use my site in production without this being fixed.
How to re-produce:
After submitting the admin/config/people/accounts form, even when not changing the E-mails settings, user_mail_ variables get set. This forces the code below to run.
Problem code (user.module 2592):
Any smart ideas on how we could fix this?
Comment #5
fenda commentedComment #6
fenda commentedI see there is another issue like this, but it is for 6.x-dev: http://drupal.org/node/163165
Wasn't sure how to proceed, but sticking to this one for now.
Comment #7
dddave commentedSorry to be pain here but I am going to close this issue again because it is meandering (starting as a D6 issue). Please create a new issue with your stuff from #4 and set it at least against 7-dev. The ubercorrect way would be to set against D8 because it would have to be fixed there first. I don't know though how user module will change in D8 so setting against D7 might be ok. The priority would be "normal" btw.
Comment #8
Jānis Bebrītis commentedDon't want to reopen the issue, but here's a
#4#3 made into patch