trac494 email is now in recipient's language

darcs-hash:20081204203433-099f7-41be8f47b2a8e647414225f26318da005144006d.gz
This commit is contained in:
millette 2008-12-04 15:34:33 -05:00
parent f9c88fe09c
commit 9c3c1e0272
2 changed files with 19 additions and 7 deletions

View File

@ -115,6 +115,8 @@ function mail_subscribe_notify($listenee, $listener) {
function mail_subscribe_notify_profile($listenee, $other) { function mail_subscribe_notify_profile($listenee, $other) {
if ($listenee->email && $listenee->emailnotifysub) { if ($listenee->email && $listenee->emailnotifysub) {
// use the recipients localization
common_init_locale($listenee->language);
$profile = $listenee->getProfile(); $profile = $listenee->getProfile();
$name = $profile->getBestName(); $name = $profile->getBestName();
$long_name = ($other->fullname) ? ($other->fullname . ' (' . $other->nickname . ')') : $other->nickname; $long_name = ($other->fullname) ? ($other->fullname . ' (' . $other->nickname . ')') : $other->nickname;
@ -130,6 +132,9 @@ function mail_subscribe_notify_profile($listenee, $other) {
common_config('site', 'name'), common_config('site', 'name'),
$other->profileurl, $other->profileurl,
common_config('site', 'name')); common_config('site', 'name'));
// reset localization
common_init_locale();
mail_send($recipients, $headers, $body); mail_send($recipients, $headers, $body);
} }
} }

View File

@ -131,17 +131,24 @@ function common_end_xml() {
$xw->flush(); $xw->flush();
} }
function common_init_locale($language=null) {
if(!$language) {
$language = common_language();
}
putenv('LANGUAGE='.$language);
putenv('LANG='.$language);
return setlocale(LC_ALL, $language . ".utf8",
$language . ".UTF8",
$language . ".utf-8",
$language . ".UTF-8",
$language);
}
function common_init_language() { function common_init_language() {
mb_internal_encoding('UTF-8'); mb_internal_encoding('UTF-8');
$language = common_language(); $language = common_language();
# So we don't have to make people install the gettext locales # So we don't have to make people install the gettext locales
putenv('LANGUAGE='.$language); $locale_set = common_init_locale($language);
putenv('LANG='.$language);
$locale_set = setlocale(LC_ALL, $language . ".utf8",
$language . ".UTF8",
$language . ".utf-8",
$language . ".UTF-8",
$language);
bindtextdomain("laconica", common_config('site','locale_path')); bindtextdomain("laconica", common_config('site','locale_path'));
bind_textdomain_codeset("laconica", "UTF-8"); bind_textdomain_codeset("laconica", "UTF-8");
textdomain("laconica"); textdomain("laconica");