FW: [rt-users] choosing template on the fly
Dimitry Faynerman
dimitry.faynerman at hypermediasystems.com
Tue May 11 10:55:23 EDT 2004
-----Original Message-----
From: Ruslan U. Zakirov [mailto:cubic at acronis.ru]
Subject: Re: FW: [rt-users] choosing template on the fly
Please, share short soluton summary with other.
Best regards. Ruslan.
Ok, so what I needed was to use different template depending on the uesr's
language. So I modified lib/RT/Action/SendEmali.pm slightly.
First it checks the language from user's profile. If, for example, it's
Japanese, then it replaces current template with the template which name has
"(ja)" at the end. So, instead of, for example, "Autoreply" template, it
will try to find template "Autoreply (ja)".
Here's the code:
sub Prepare {
my $self = shift;
# This actually populates the MIME::Entity fields in the Template Object
unless ( $self->TemplateObj ) {
$RT::Logger->warning("No template object handed to $self\n");
}
# my changes start here ===============================================
# Use japanese template (if exists) if user's language is japanese
my $UserObj = RT::User->new( $RT::SystemUser );
$UserObj->Load($self->TicketObj->Requestors->UserMembersObj->First->Id);
if (($self->TemplateObj) &&
((!$UserObj->Lang) || ($UserObj->Lang ne 'en'))) {
my $rememberEnglishId = $self->TemplateObj->Id;
$self->TemplateObj->Load(
$self->TemplateObj->Name . " (" . $UserObj->Lang . ")");
if (! $self->TemplateObj->Id) {
$self->TemplateObj->Load($rememberEnglishId);
}
}
# my changes end here ===============================================
unless ( $self->TransactionObj ) {
$RT::Logger->warning("No transaction object handed to $self\n");
}
........
........
}
-Dimitry
More information about the rt-users
mailing list