The content of the notification mails should be in t().

There is also a typo in line 29: "set" -> "sent".

CommentFileSizeAuthor
translate_mail.patch.txt2.35 KBStandart

Comments

dww’s picture

Status: Active » Closed (won't fix)

Fixed the typo, thanks.

However, I won't be changing the message text into translatable strings. This is broken in D5 and before. It's now fixed in D6 (see http://drupal.org/node/82499). However, if you did this in D5, site users could be getting emails in languages they don't understand at all due to weirdness with what language happens to be active when these emails are getting triggered (e.g. admin approves account, admin's prefered language is Spanish, user's prefered is Turkish, user gets email in Spanish).

And, since this module's functionality is now part of D6's user.module, all of this works perfectly in the right languages. ;)

Cheers,
-Derek

Standart’s picture

Ok, I see.

It's good to hear that this has been fixed in D6. Anyways, D5 will be around for another year maybe. Though of course I agree that this is a bug, I think this module should behave like core. That's what I expect especially as it's common to use core features and this module together. I guess many sites only use one language and it's a lot to translate as it's not part of any translation available. In fact I just did a German translation including the mail content.

If you're using this module and translations you will have to deal with this problem anyway, as translated mails will be sent to the user by the user.module. This is even recommended by this module.

I'd vote for translating mail content anyway, as the situation now isn't any better but incompatible with core.

Thanks!

dww’s picture

Status: Closed (won't fix) » Needs review

hrm, ok. i guess you're right. this actually came up when i first took over this module, and i asked some translator-aware folks (killes, i believe), and he recommended *not* translating these strings. but, given that user.module does, i guess that's the most sane approach, even though it's really broken in some cases.

dww’s picture

Status: Needs review » Fixed

Fixed in HEAD, DRUPAL-5 and DRUPAL-4-7. I also regenerated the translation templates on all branches. Thanks.

Anonymous’s picture

Status: Fixed » Closed (fixed)
pulpzebra’s picture

However, the translation of email contents doesn't solve the problem of sending emails to user speaking a different language than the admin's one.
I found a simple workaround this way:

  1. get the "language" property from $user object;
  2. introduce a new parameter in the user_status_something function, called eg $user_locale
  3. inside the function i temporarily switch the global $locale according to the $user_locale parameter, invoke the t function and then switch back to the original locale.
function user_status_activated_body($user_locale) {
  global $locale;
  if ($user_locale != $locale) {
    $old_locale = $locale;
    $locale = $user_locale;
  }
  $text = t("%username,\n\nYour account at %site has been activated.\n\nYou may now log in by clicking on this link or copying and pasting it in your browser:\n\n%login_url\n\nThis is a one-time login, so it can be used only once.\n\nAfter logging in, you will be redirected to %edit_uri so you can change your password.\n\nOnce you have set your own password, you will be able to log in to %login_uri in the future using the following username:\n\nusername: %username\n");
  if ($old_locale != $user_locale) {
    $locale = $old_locale;
  }
  return $text;
}

I don't believe this is the correct approach, "drupally" speaking, and since I still haven't tried 6.x, can't tell wether this problem has been solved or not.

dww’s picture

Drupal 6 indeed solves this problem natively. I won't be back-porting anything like this to the 5.x contrib version of this module, sorry, I just have way too many other things to worry about.