Skip to content

Commit

Permalink
Lang stuff.
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.eprints.org/eprints/trunk/system@338 9491667e-5006-0410-a446-efbe8990b998
  • Loading branch information
cgutteridge committed Feb 8, 2001
1 parent 0a98f07 commit 04a0489
Show file tree
Hide file tree
Showing 5 changed files with 125 additions and 56 deletions.
37 changes: 36 additions & 1 deletion cfg/intl/english
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,40 @@ dude = Internationalisation Rocks.

<file Citation.pm>
unknowneprint = Unknown EPrint field $(1) in "$(2)"
na = "N/A"
na = N/A
</file>

<file UserForm.pm>
dontknow = I don't know who you are
recfor = Record for $(1)
blurb = Please enter correct information about yourself for our records. This information will be useful to us and readers of your papers. You don't have to supply all this information if you don't want to; you need only fill out those fields marked with a * to start using the archive.
changeemail = For instructions on how to change your e-mail address, $(1).
clickhere = click here
formincorrect = The form doesn't seem to be filled out correctly:
completeform = Please complete the form before continuing.
problemupdating = There was a problem reading the posted data and updating the database. Please try again later
usernotmatch = Username in form $(1) doesn't match object username $(2)
</file>

<file User.pm>
missedfield = You haven't filled out the required $(1) field.
weclome = Welcome to $(1)!
reminder = Dear $(1) User,\n\n$(2)Your username and password for the site are:\n\nUser name: $(3)\nPassword: $(4)\n\nIf you didn't expect this e-mail, please contact the site\nadministrator at:\n\n$(5)\n
remindersub = Your username and password
newuser = New $(1) User
newstaff = New $(1) Staff
</file>

<file Subscription.pm>
sendupdates = Send updates: $(1)
weekly = weekly
daily = daily
monthly = monthly
never = never
notopenrec = Couldn't open user record for user $(1) (sub ID $(2))
blurb = This mail contains your $(1) subscription to $(2).\n\nTo cancel, temporarily disable or alter your subscription,\nvisit the following Web page:\n\n $(3)\n\n
newsub = One new submission was received.
newsubs = $(1) new submissions were received.
subsubj = Subscription
failsend = Failed to send subscription to user $(1): $(2)
</file>
14 changes: 12 additions & 2 deletions lib/Language.pm
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
######################################################################
#
# EPrints Language class module
#
# This module represents a language, and provides methods for
# retrieving phrases in that language (from a config file)
#
# All errors in the Language file are in english, otherwise we could
# get into a loop!
#
######################################################################
#
# __COPYRIGHT__
Expand Down Expand Up @@ -201,8 +209,10 @@ sub make_file_phrases
# Get the phrase out of a line "id = phrase";
elsif( /^\s*([a-z0-9_]+)\s*=\s*(.*)$/i )
{
# maybe process \n's etc?
$self->{data}->{$filename}->{$1}=$2;
my ( $key , $val ) = ( $1 , $2 );
# convert \n to actual CR's
$val =~ s/\\n/\n/g;
$self->{data}->{$filename}->{$key}=$val;
}
# Can ignore everything else
}
Expand Down
51 changes: 33 additions & 18 deletions lib/Subscription.pm
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,11 @@ sub render_subscription_form
my $html = $self->{searchexpression}->render_search_form( 1, 0 );
my @all_fields = EPrints::MetaInfo::get_subscription_fields();

$html .= "<CENTER><P>Send updates: ";
$html .= $self->{session}->{render}->input_field(
EPrints::MetaInfo::find_field( \@all_fields, "frequency" ),
$self->{frequency} );
$html .= "<CENTER><P>";
$html .= $self->{session}->{lang}->phrase( "sendupdates",
$self->{session}->{render}->input_field(
EPrints::MetaInfo::find_field( \@all_fields, "frequency" ),
$self->{frequency} ) );
$html .= "</P></CENTER>\n";

return( $html );
Expand Down Expand Up @@ -416,8 +417,9 @@ sub process
{
EPrints::Log::log_entry(
"Subscription",
"Couldn't open user record for user $self->{username} (sub ID ".
"$self->{subid})" );
EPrints::Language::logphrase( "notopenrec",
$self->{username},
$self->{subid} ) );
return( 0 );
}

Expand Down Expand Up @@ -480,17 +482,28 @@ sub process
# Don't send a mail if we've retrieved nothing
return( 1 ) if( scalar @eprints == 0 );

my $freqphrase = $self->{session}->{lang}->phrase($freq);

# Put together the body of the message. First some blurb:
my $body = "This mail contains your $freq subscription to ".
"$EPrintSite::SiteInfo::sitename.\n\nTo cancel, temporarily disable ".
"or alter your subscription, visit the following Web page:\n\n".
"$EPrintSite::SiteInfo::server_perl/users/subscribe\n\n";
my $body = $self->{session}->{lang}->phrase(
"blurb",
$freqphrase,
$EPrintSite::SiteInfo::sitename,
"$EPrintSite::SiteInfo::server_perl/users/subscribe" );

# Then how many we got
$body .= " ==========\n\n";
$body .= " ".scalar @eprints." new submission";
$body .= ( scalar @eprints==1 ? " was" : "s were" );
$body .= " received.\n\n\n";
$body .= " ";
if ( scalar @eprints==1 )
{
$body .= $self->{session}->{lang}->phrase( "newsub" );
}
else
{
$body .= $self->{session}->{lang}->phrase( "newsubs",
scalar @eprints );
}
$body .= "\n\n\n";

# Then citations, with links to appropriate pages.
foreach (@eprints)
Expand All @@ -501,15 +514,17 @@ sub process
}

# Send the mail.
$success = EPrints::Mailer::send_mail( $user->full_name(),
$user->{email},
"Subscription",
$body );
$success = EPrints::Mailer::send_mail(
$user->full_name(),
$user->{email},
$self->{session}->{lang}->phrase( "subsubj" ),
$body );

unless( $success )
{
EPrints::Log::log_entry(
"Subscription",
"Failed to send subscription to user $user->{username}: $!" );
EPrints::Language::logphrase( "failsend", $user->{username}, $! ) );
}
}

Expand Down
38 changes: 23 additions & 15 deletions lib/User.pm
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,8 @@ sub validate
$self->{$field->{name}} eq "" ) )
{
push @all_problems,
"You haven't filled out the required $field->{displayname} field.";
$self->{session}->{lang}->phrase( "missedfield",
$field->{displayname} );
}
else
{
Expand Down Expand Up @@ -412,11 +413,21 @@ sub send_introduction
{
my( $self ) = @_;

my $subj;
if ( $self->{groups} eq "Staff" )
{
$subj = "newstaff";
}
else
{
$subj = "newuser";
}
# Try and send the mail
return( EPrints::Mailer->prepare_send_mail(
"New $EPrintSite::SiteInfo::sitename $self->{groups}",
$self->{lang}->parse( $subj , $EPrintSite::SiteInfo::sitename ),
$self->{email},
"Welcome to $EPrintSite::SiteInfo::sitename!",
$self->{session}->{lang}->parse( "welcome",
$EPrintSite::SiteInfo::sitename ),
$EPrintSite::SiteInfo::template_user_intro,
$self ) );
}
Expand All @@ -436,21 +447,18 @@ sub send_reminder
{
my( $self, $message ) = @_;

my $full_message =
"Dear $EPrintSite::SiteInfo::sitename User,\n\n";

$full_message .= "$message\n\n" if( defined $message );

$full_message .= "Your username and password for the site are:\n\n".
"User name: $self->{username}\n".
"Password: $self->{passwd}\n\n".
"If you didn't expect this e-mail, please contact the site\n".
"administrator at:\n\n".
"$EPrintSite::SiteInfo::admin\n";
my $full_message = $self->{session}->{lang}->phrase(
"reminder",
$EPrintSite::SiteInfo::sitename,
( defined $message ? "$message\n\n" : "" ),
$self->{username},
$self->{passwd},
$EPrintSite::SiteInfo::admin );

return( EPrints::Mailer::send_mail( $self->full_name(),
$self->{email},
"Your username and password",
$self->{session}->{lang}->phrase(
"remindersub" ),
$full_message ) );
}

Expand Down
41 changes: 21 additions & 20 deletions lib/UserForm.pm
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@ sub process
if( !defined $self->{user} )
{
# Can't find the user
$self->{session}->{render}->render_error( "I don't know who you are",
$self->{redirect} );
$self->{session}->{render}->render_error(
$self->{session}->{lang}->phrase( "dontknow" ),
$self->{redirect} );
return;
}

Expand All @@ -74,18 +75,15 @@ sub process
if( $self->{session}->{render}->seen_form() == 0 ||
$self->{session}->{render}->internal_button_pressed() )
{
print $self->{session}->{render}->start_html( "Record for $full_name" );
print $self->{session}->{render}->start_html(
$self->{session}->{lang}->phrase( "recfor", $full_name ) );

# Blurb
print "<P>Please enter correct information about yourself for our ".
"records. This information will be useful to us and readers of your ".
"papers. You don't have to supply all this information if you don\'t ".
"want to; you need only fill out those fields marked with a * to ".
"start using the archive.</P>\n";
print "<P>".$self->{session}->{lang}->phrase( "blurb" )."</P>\n";

print "<P>For instructions on how to change your e-mail address, ".
print "<P>".$self->{session}->{lang}->phrase(
"changeemail",
"<a href=\"$EPrintSite::SiteInfo::server_static/register.html\">".
"click here</A>.</P>\n";
$self->{session}->{lang}->phrase( "clickhere" )."</A>" )."</P>";

$self->render_form();

Expand All @@ -107,18 +105,21 @@ sub process
}
else
{
print $self->{session}->{render}->start_html(
"Record for $full_name" );
print $self->{session}->{render}->start_html(
$self->{session}->{lang}->phrase( "recfor", $full_name ) );

print "<P>The form doesn\'t seem to be filled out correctly:</P>\n".
"<UL>\n";
print "<P>".$self->{session}->{lang}->phrase( "formincorrect" ).
"</P>\n";
print "<UL>\n";

foreach (@$problems)
{
print "<LI>$_</LI>\n";
}

print "</UL>\n<P>Please complete the form before continuing.</P>\n";
print "</UL>\n";
print "<P>".$self->{session}->{lang}->phrase( "completeform" ).
"</P>\n";

$self->render_form();

Expand All @@ -128,8 +129,7 @@ sub process
else
{
$self->{session}->{render}->render_error(
"There was a problem reading the posted data and updating the ".
"database. Please try again later",
$self->{session}->{lang}->phrase( "problemupdating" ),
$self->{redirect} );
}
}
Expand Down Expand Up @@ -208,8 +208,9 @@ sub update_from_form
my $form_id = $self->{session}->{render}->param( "username" );
EPrints::Log::log_entry(
"User",
"Username in form $form_id doesn't match object username ".
"$self->{username}" );
EPrints::Language::logphrase( "usernotmatch",
$form_id,
$self->{username} ) );

return( 0 );
}
Expand Down

0 comments on commit 04a0489

Please sign in to comment.