Bug 14224: Make strings translatable

The strings should be translatable.
This patch also removes the error as it appears that we only have 1
error.
To improve we could surround the store with an eval.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Marc Véron <veron@veron.ch>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
This commit is contained in:
Jonathan Druart 2017-02-01 16:38:37 +01:00 committed by Kyle M Hall
parent a7df1afe60
commit 88852ffbb0
2 changed files with 11 additions and 18 deletions

View file

@ -953,9 +953,9 @@ Using this account is not recommended because some parts of Koha will not functi
if(origvalue != value) { if(origvalue != value) {
if(origvalue != "") if(origvalue != "")
$btn_save.text('Submit changes'); $btn_save.text(_("Submit changes"));
else else
$btn_save.text('Submit note'); $btn_save.text(_("Submit note"));
$btn_save.show(); $btn_save.show();
} else { } else {
$btn_save.hide(); $btn_save.hide();
@ -986,30 +986,28 @@ Using this account is not recommended because some parts of Koha will not functi
$("#notesaved").addClass("alert-info"); $("#notesaved").addClass("alert-info");
$noteinput.data('origvalue', data.note); $noteinput.data('origvalue', data.note);
$noteinput.val(data.note); $noteinput.val(data.note);
message = "<p>Your note about " + title + " has been saved and sent to the library.</p>"; message = "<p>" + _("Your note about %s has been saved and sent to the library.").format(title) + "</p>";
message += "<p style=\"font-style:italic;\">" + data.note + "</p>";
$self.hide(); $self.hide();
} else if(data.status == 'removed') { } else if(data.status == 'removed') {
$("#notesaved").removeClass("alert-error"); $("#notesaved").removeClass("alert-error");
$("#notesaved").addClass("alert-info"); $("#notesaved").addClass("alert-info");
$noteinput.data('origvalue', ""); $noteinput.data('origvalue', "");
$noteinput.val(""); $noteinput.val("");
message = "<p>Your note about " + title + " was removed.</p>"; message = "<p>" + _("Your note about %s was removed.").format(title) + "</p>";
$self.hide(); $self.hide();
} else { } else {
$("#notesaved").removeClass("alert-info"); $("#notesaved").removeClass("alert-info");
$("#notesaved").addClass("alert-error"); $("#notesaved").addClass("alert-error");
message = "<p>Your note about " + title + " could not be saved.</p>" + message = "<p>" + _("Your note about %s could not be saved.").format(title) + "</p>";
"<p style=\"font-weight:bold;\">" + data.error + "</p>"; message += "<p style=\"font-weight:bold;\">" + _("Something went wrong. The note has not been saved") + "</p>";
} }
message += "<p style=\"font-style:italic;\">" + data.note + "</p>";
$("#notesaved").html(message); $("#notesaved").html(message);
}) })
.fail(function(data) { .fail(function(data) {
$("#notesaved").removeClass("alert-info"); $("#notesaved").removeClass("alert-info");
$("#notesaved").addClass("alert-error"); $("#notesaved").addClass("alert-error");
var message = "<p>Your note about " + title + " could not be saved.</p>" + var message = "<p style=\"font-weight:bold;\">" + _("Something went wrong. The note has not been saved") + "</p>";
"<p style=\"font-weight:bold;\">Ajax request has failed.</p>";
$("#notesaved").html(message); $("#notesaved").html(message);
}) })
.always(function() { .always(function() {

View file

@ -56,7 +56,6 @@ if ($is_ajax) {
my $issue_id = $query->param('issue_id'); my $issue_id = $query->param('issue_id');
my $clean_note = $scrubber->scrub($note); my $clean_note = $scrubber->scrub($note);
my $status = "saved"; my $status = "saved";
my $error = "";
my ($member, $issue); my ($member, $issue);
my ( $template, $borrowernumber, $cookie ) = C4::Auth::get_template_and_user({ my ( $template, $borrowernumber, $cookie ) = C4::Auth::get_template_and_user({
@ -72,14 +71,11 @@ if ($is_ajax) {
$issue = Koha::Checkouts->find($issue_id); $issue = Koha::Checkouts->find($issue_id);
if ( $issue->borrowernumber != $borrowernumber ) { if ( $issue->borrowernumber != $borrowernumber ) {
$status = "fail"; $status = "fail";
$error = "Invalid issue id!";
} }
} else {
$status = "fail";
$error = "Invalid issue id!";
} }
if ( (not $error) && $issue->set({ notedate => dt_from_string(), note => $clean_note })->store ) { if ( $issue ) {
$issue->set({ notedate => dt_from_string(), note => $clean_note })->store;
if($clean_note) { # only send email if note not empty if($clean_note) { # only send email if note not empty
my $branch = Koha::Libraries->find( $issue->branchcode ); my $branch = Koha::Libraries->find( $issue->branchcode );
my $biblio = GetBiblioFromItemNumber($issue->itemnumber); my $biblio = GetBiblioFromItemNumber($issue->itemnumber);
@ -98,10 +94,9 @@ if ($is_ajax) {
} }
} else { } else {
$status = "fail"; $status = "fail";
$error = "Perhaps the item has already been checked in?";
} }
my $response = "{\"status\": \"$status\", \"note\": \"$clean_note\", \"issue_id\": \"$issue_id\", \"error\": \"$error\"}"; my $response = "{\"status\": \"$status\", \"note\": \"$clean_note\", \"issue_id\": \"$issue_id\"}";
output_with_http_headers($query, undef, $response, 'js'); output_with_http_headers($query, undef, $response, 'js');
exit; exit;
} # END Issue Note } # END Issue Note