Internationalized system messages.

This commit is contained in:
Martin Kamerbeek 2010-05-31 16:22:22 +02:00
parent bcb265e188
commit 2490e166d3
15 changed files with 422 additions and 79 deletions

View file

@ -7,17 +7,6 @@ use Class::C3;
use WebGUI::Macro;
use Tie::IxHash;
##----------------------------------------------------------------------------
#sub configureMailingForm {
# my $self = shift;
# my $f = WebGUI::HTMLForm->new( $session, { action => $self->getUrl } );
# $f->hidden(
# name => 'func'
# value => '
#
# return $f;
#}
#----------------------------------------------------------------------------
sub definition {
my $class = shift;
@ -28,7 +17,7 @@ sub definition {
tie my %properties, 'Tie::IxHash', (
mailStyleTemplateId => {
fieldType => 'template',
label => 'Mail template',
label => $i18n->get( 'mail template' ),
tab => 'mailable',
namespace => 'style',
},
@ -46,9 +35,11 @@ sub definition {
#----------------------------------------------------------------------------
sub getEditTabs {
my $self = shift;
my $self = shift;
my $session = $self->session;
my $i18n = WebGUI::International->new( $session,'AssetAspect_Mailable' );
return ( $self->next::method, [ 'mailable', 'Mailing list', 9 ] );
return ( $self->next::method, [ 'mailable', $i18n->get( 'mailing' ), 9 ] );
}
#----------------------------------------------------------------------------
@ -73,15 +64,18 @@ sub getSubject {
#----------------------------------------------------------------------------
sub getMailingProperties {
my $self = shift;
my $self = shift;
my $session = $self->session;
my $i18n = WebGUI::International->new( $session,'AssetAspect_Mailable' );
tie my %properties, 'Tie::IxHash', (
subject => {
fieldType => 'text',
label => 'subject',
label => $i18n->get( 'subject' ),
},
styleTemplateId => {
fieldType => 'template',
label => 'Style template',
label => $i18n->get( 'mail template' ),
defaultValue=> $self->get('mailStyleTemplateId'),
namespace => 'style',
},
@ -130,16 +124,5 @@ sub processContentAsUser {
return $content;
}
##----------------------------------------------------------------------------
#sub www_configureMailing {
# my $self = shift;
#
# my $f = $self->configureMailingForm;
#
# $f->submit( 'Next step' );
#
# return $self->processStyle( $f->print );
#}
1;

View file

@ -14,63 +14,63 @@ sub definition {
my $class = shift;
my $session = shift;
my $definition = shift;
# my $i18n = WebGUI::International->new( $session,'AssetAspect_Subscriber' );
my $i18n = WebGUI::International->new( $session,'AssetAspect_Subscriber' );
tie my %properties, 'Tie::IxHash', (
subscriptionGroupId => {
fieldType => 'subscriptionGroup',
label => 'Subscription group',
label => $i18n->get( 'Subscription group' ),
tab => 'subscription',
noFormPost => 1,
},
subscriptionEnabled => {
fieldType => 'yesNo',
defaultValue => 1,
label => 'Enable subscription',
label => $i18n->get( 'Enable subscription' ),
tab => 'subscription',
},
alwaysConfirmSubscription => {
fieldType => 'yesNo',
defaultValue => 0,
label => 'Always require subscription confirmation',
label => $i18n->get( 'require confirmation' ),
tab => 'subscription',
},
allowAnonymousSubscription => {
fieldType => 'yesNo',
defaultValue => 1,
label => 'Allow anonymous subscription',
label => $i18n->get( 'allow anonymous' ),
tab => 'subscription',
},
confirmationRequiredTemplateId => {
fieldType => 'template',
defaultValue => 'd1tQuv-OlPwgz6PnLcq-hA',
label => 'Confirmation required template',
label => $i18n->get( 'confirmation required template' ),
namespace => 'Subscriber/ConfirmationRequired',
tab => 'subscription',
},
confirmationEmailSubject => {
fieldType => 'text',
defaultVale => 'Confirm your subscription mutation',
label => 'Confirmation email subject',
defaultValue => 'Confirm your subscription mutation',
label => $i18n->get( 'confirmation email subject' ),
tab => 'subscription',
},
confirmationEmailTemplateId => {
fieldType => 'template',
defaultValue => '4aLemgMrTFhG3eqg57jCpQ',
label => 'Confirmation email template',
label => $i18n->get( 'confirmation email template' ),
namespace => 'Subscriber/ConfirmationEmail',
tab => 'subscription',
},
noMutationEmailSubject => {
fieldType => 'text',
defaultVale => '(Un)subscribe result',
label => 'No mutation email subject',
defaultValue => '(Un)subscribe result',
label => $i18n->get( 'no mutation subject' ),
tab => 'subscription',
},
noMutationEmailTemplateId => {
fieldType => 'template',
defaultValue => 'Q8t7dUqMk05D2m7Jbgg4BQ',
label => 'No mutation email template',
label => $i18n->get( 'no mutation template' ),
namespace => 'Subscriber/NoMutationEmail',
tab => 'subscription',
},
@ -101,8 +101,10 @@ sub duplicate {
#----------------------------------------------------------------------------
sub getEditTabs {
my $self = shift;
my $session = $self->session;
my $i18n = WebGUI::International->new( $session, 'AssetAspect_Subscriber' );
return ( $self->next::method, [ 'subscription', 'Subscription', 9 ] );
return ( $self->next::method, [ 'subscription', $i18n->get('tab name'), 9 ] );
}
#----------------------------------------------------------------------------
@ -174,7 +176,7 @@ sub appendSubscriptionFormVars {
my $self = shift;
my $var = shift || {};
my $session = $self->session;
my $i18n = WebGUI::International->new( $session, 'Asset_NewsletterCollection' );
my $i18n = WebGUI::International->new( $session, 'AssetAspect_Subscriber' );
# Setup form controls
my $formHeader =
@ -252,6 +254,7 @@ sub sendSubscriptionConfirmation {
my $code = shift;
my $action = shift || 'subscribe';
my $session = $self->session;
my $i18n = WebGUI::International->new( $session, 'AssetAspect_Subscriber' );
my $var = $self->getEmailVars( $user );
my $url = $session->url->getSiteURL . $self->getUrl( "func=confirmMutation;code=$code" );
@ -272,7 +275,7 @@ sub sendSubscriptionConfirmation {
}
else {
$session->log->error( "Cannot instanciate confirmation email template with id [$templateId]" );
$mail->addText( "Click here to confirm your (un)subscription: $url" );
$mail->addText( sprintf $i18n->get( 'click to confirm fallback' ), $url );
}
$mail->send;
@ -286,6 +289,7 @@ sub sendNoMutationEmail {
my $user = shift;
my $action = shift || 'subscribe';
my $session = $self->session;
my $i18n = WebGUI::International->new( $session, 'AssetAspect_Subscriber' );
my $var = $self->getEmailVars( $user );
$var->{ actionIsSubscribe } = $action eq 'subscribe';
@ -303,7 +307,7 @@ sub sendNoMutationEmail {
else {
$session->log->error( "Cannot instanciate no mutation email template with id [$templateId]" );
if ( $action eq 'subscribe' ) {
$mail->addText( "This email address is already subscribed to " . $self->get('title') );
$mail->addText( sprintf $i18n->get('already subscribed fallback'), $self->get('title') );
}
}
@ -312,6 +316,7 @@ sub sendNoMutationEmail {
return;
}
#----------------------------------------------------------------------------
sub logConfirmation {
my $self = shift;
my $code = shift || return;
@ -333,6 +338,7 @@ sub logConfirmation {
return;
};
#----------------------------------------------------------------------------
sub logRequest {
my $self = shift;
my $type = shift || croak 'No type passed to logrequest';
@ -453,6 +459,7 @@ sub www_processSubscription {
my $self = shift;
my $session = $self->session;
my $form = $session->form;
my $i18n = WebGUI::International->new( $session, 'AssetAspect_Subscriber' );
my $action = $form->get( 'action' );
return unless $action eq 'subscribe' || $action eq 'unsubscribe';
@ -486,7 +493,7 @@ sub www_processSubscription {
}
}
else {
return $self->processStyle( 'Anonymous subscription is not allowed. Please log in to (un)subscribe' );
return $self->processStyle( $i18n->get( 'anonnymous not allowed' ) );
}
return $self->processStyle( $self->processTemplate( {}, $self->get('confirmationRequiredTemplateId') ) );