From: Taku Amano Date: Tue, 5 May 2009 16:54:02 +0000 (+0900) Subject: Added LoveLetter's attribute 'language'. X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=9239069bfff6df18d2103d107b9a3a675c3f193b;p=mt-acme%2FLovers.git Added LoveLetter's attribute 'language'. --- diff --git a/config.yaml b/config.yaml index 7efd319..86830b6 100644 --- a/config.yaml +++ b/config.yaml @@ -33,7 +33,7 @@ doc_link: http://mt-acme.sourceforge.jp/lovers/ l10n_class: Lovers::L10N # objects -schema_version: 2 +schema_version: 3 object_types: love_letter: Lovers::LoveLetter diff --git a/lib/Lovers/App/LoveLetter.pm b/lib/Lovers/App/LoveLetter.pm index de113a4..f88df08 100644 --- a/lib/Lovers/App/LoveLetter.pm +++ b/lib/Lovers/App/LoveLetter.pm @@ -77,6 +77,7 @@ sub _hdlr_love_letter { author_id => $entry ? $entry->author_id : $tmpl->modified_by, from => $args->{'from'} || '', to => $args->{'to'} || '', + language => $args->{'language'} || '', }); if ((! $obj->sent_on || $obj->sent_on =~ m/^0/) && $obj->to) { @@ -101,6 +102,13 @@ sub _hdlr_love_letter { $param->{'permalink'} =~ s/#.*//; $param->{'permalink'} .= '#password' } + + my $current_language = undef; + if (my $lang = $param->{'language'}) { + $current_language = MT->current_language; + MT->set_language($lang); + } + my $tmpl = $plugin->load_tmpl('mail_love_letter.tmpl'); my $body = MT->translate_templatized( $tmpl->output($param) @@ -116,6 +124,10 @@ sub _hdlr_love_letter { my $charset = $cfg->MailEncoding || $cfg->PublishCharset; $head{'Content-Type'} = qq(text/plain; charset="$charset"); + if ($current_language) { + MT->set_language($current_language); + } + require MT::Mail; MT::Mail->send( \%head, $body ) or return $app->error( MT::Mail->errstr() ); @@ -133,6 +145,12 @@ sub _hdlr_love_letter { my $builder = $ctx->stash('builder'); my $tokens = $ctx->stash('tokens'); + my $current_language = undef; + if (my $lang = $args->{'language'}) { + $current_language = MT->current_language; + MT->set_language($lang); + } + defined($res = $builder->build($ctx, $tokens, $cond)) or return $ctx->error( $builder->errstr ); @@ -358,6 +376,10 @@ $res __EOF__ + if ($current_language) { + MT->set_language($current_language); + } + $res; } @@ -428,6 +450,12 @@ __MSG__ $param->{'message'} = $app->param('response') || ''; $param->{'ok'} = $app->param('ok') ? 1 : 0; + my $current_language = undef; + if (my $lang = $param->{'language'}) { + $current_language = MT->current_language; + MT->set_language($lang); + } + my $tmpl = $plugin->load_tmpl('mail_response.tmpl'); my $body = MT->translate_templatized( $tmpl->output($param) @@ -443,6 +471,10 @@ __MSG__ my $charset = $cfg->MailEncoding || $cfg->PublishCharset; $head{'Content-Type'} = qq(text/plain; charset="$charset"); + if ($current_language) { + MT->set_language($current_language); + } + require MT::Mail; MT::Mail->send( \%head, $body ) or return $app->error( MT::Mail->errstr() ); diff --git a/lib/Lovers/LoveLetter.pm b/lib/Lovers/LoveLetter.pm index f6007b1..f31fb99 100644 --- a/lib/Lovers/LoveLetter.pm +++ b/lib/Lovers/LoveLetter.pm @@ -35,6 +35,7 @@ __PACKAGE__->install_properties({ 'from' => 'string(255)', 'to' => 'string(255)', + 'language' => 'string(10)', 'sent_on' => 'datetime', },