From e2cc7ff38ebfdef049433674c8cedadee6eec00d Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Thu, 18 Jun 2020 16:28:28 +0000 Subject: [PATCH] Bug 25321: (Part 1) Move translatable strings out of strings.inc into checkouts.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch movies translatable strings out of an include file and into the JavaScript file where the string is used. It is no longer necessary to have such strings in a Template::Toolkit file in order for them to be translated. To test, apply the patch and test that the correct strings appear in the staff client. For instance: - The "Claim returned" button in the patron's table of checkouts. - The "Today's checkouts" and "Previous checkouts" headers in the table of checkouts. - The "On hold" message in the "Renew" column in the table of checkouts when the item is on hold for another patron. Test that the correct strings are translatable. In this example I'm testing fr-FR: - Update a translation: > cd misc/translator > perl translate update fr-FR - Open the corresponding .po file for the strings pulled from JavaScript e.g. misc/translator/po/fr-FR-messages-js.po - Locate strings pulled from prog/js/checkouts.js for translation, e.g.: #: koha-tmpl/intranet-tmpl/prog/js/checkouts.js:560 msgid "Claim returned" msgstr "" - Edit the "msgstr" string however you want (it's just for testing) - Install the updated translation: > perl translate install fr-FR In the staff client, switch to the language you're testing. Confirm that your translated string appears. In the above example, by opening the checkouts page for a patron who has items checked out. In the "Déclarés rendus" column, confirm that the "Claim returned" button text appears as you translated it. --- .../intranet-tmpl/prog/en/includes/strings.inc | 79 ++++++---------------- koha-tmpl/intranet-tmpl/prog/js/checkouts.js | 74 ++++++++++---------- 2 files changed, 59 insertions(+), 94 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/strings.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/strings.inc index 26aed46765..eaefa03997 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/strings.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/strings.inc @@ -1,61 +1,26 @@ diff --git a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js b/koha-tmpl/intranet-tmpl/prog/js/checkouts.js index 1b9b4a213d..dab041ee01 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js +++ b/koha-tmpl/intranet-tmpl/prog/js/checkouts.js @@ -1,4 +1,4 @@ -/* global PATRON_NOTE */ +/* global __ */ $(document).ready(function() { $.ajaxSetup ({ cache: false }); @@ -115,14 +115,14 @@ $(document).ready(function() { content = ""; if ( data.returned ) { - content = CIRCULATION_RETURNED; + content = __("Checked in"); $(id).parent().parent().addClass('ok'); - $('#date_due_' + data.itemnumber).html(CIRCULATION_RETURNED); + $('#date_due_' + data.itemnumber).html(__("Checked in")); if ( data.patronnote != null ) { - $('.patron_note_' + data.itemnumber).html( PATRON_NOTE + ": " + data.patronnote); + $('.patron_note_' + data.itemnumber).html( __("Patron note") + ": " + data.patronnote); } } else { - content = CIRCULATION_NOT_RETURNED; + content = __("Unable to check in"); $(id).parent().parent().addClass('warn'); } @@ -160,24 +160,24 @@ $(document).ready(function() { var content = ""; if ( data.renew_okay ) { - content = CIRCULATION_RENEWED_DUE + " " + data.date_due; + content = __("Renewed, due:") + " " + data.date_due; $('#date_due_' + data.itemnumber).replaceWith( data.date_due ); } else { - content = CIRCULATION_RENEW_FAILED + " "; + content = __("Renew failed:") + " "; if ( data.error == "no_checkout" ) { - content += NOT_CHECKED_OUT; + content += __("not checked out"); } else if ( data.error == "too_many" ) { - content += TOO_MANY_RENEWALS; + content += __("too many renewals"); } else if ( data.error == "on_reserve" ) { - content += ON_RESERVE; + content += __("on hold"); } else if ( data.error == "restriction" ) { - content += NOT_RENEWABLE_RESTRICTION; + content += __("Not allowed: patron restricted"); } else if ( data.error == "overdue" ) { - content += NOT_RENEWABLE_OVERDUE; + content += __("Not allowed: overdue"); } else if ( data.error ) { content += data.error; } else { - content += REASON_UNKNOWN; + content += __("reason unknown"); } } @@ -250,9 +250,9 @@ $(document).ready(function() { { "mDataProp": function( oObj ) { if ( oObj.issued_today ) { - return "" + TODAYS_CHECKOUTS + ""; + return "" + __("Today's checkouts") + ""; } else { - return "" + PREVIOUS_CHECKOUTS + ""; + return "" + __("Previous checkouts") + ""; } } }, @@ -328,7 +328,7 @@ $(document).ready(function() { var onsite_checkout = ''; if ( oObj.onsite_checkout == 1 ) { - onsite_checkout += " (" + INHOUSE_USE + ")"; + onsite_checkout += " (" + __("On-site checkout") + ")"; } title += " " @@ -421,70 +421,70 @@ $(document).ready(function() { // Do nothing } else if ( oObj.can_renew_error == "on_reserve" ) { msg += "" - + "" + ON_HOLD + "" + + "" + __("On hold") + "" + ""; span_style = "display: none"; span_class = "renewals-allowed-on_reserve"; } else if ( oObj.can_renew_error == "too_many" ) { msg += "" - + NOT_RENEWABLE + + __("Not renewable") + ""; span_style = "display: none"; span_class = "renewals-allowed"; } else if ( oObj.can_renew_error == "restriction" ) { msg += "" - + NOT_RENEWABLE_RESTRICTION + + __("Not allowed: patron restricted") + ""; span_style = "display: none"; span_class = "renewals-allowed"; } else if ( oObj.can_renew_error == "overdue" ) { msg += "" - + NOT_RENEWABLE_OVERDUE + + __("Not allowed: overdue") + ""; span_style = "display: none"; span_class = "renewals-allowed"; } else if ( oObj.can_renew_error == "too_soon" ) { msg += "" - + NOT_RENEWABLE_TOO_SOON.format( oObj.can_renew_date ) + + __("No renewal before %s").format( oObj.can_renew_date ) + ""; span_style = "display: none"; span_class = "renewals-allowed"; } else if ( oObj.can_renew_error == "auto_too_soon" ) { msg += "" - + NOT_RENEWABLE_AUTO_TOO_SOON + + __("Scheduled for automatic renewal") + ""; span_style = "display: none"; span_class = "renewals-allowed"; } else if ( oObj.can_renew_error == "auto_too_late" ) { msg += "" - + NOT_RENEWABLE_AUTO_TOO_LATE + + __("Can no longer be auto-renewed - number of checkout days exceeded") + ""; span_style = "display: none"; span_class = "renewals-allowed"; } else if ( oObj.can_renew_error == "auto_too_much_oweing" ) { msg += "" - + NOT_RENEWABLE_AUTO_TOO_MUCH_OWEING + + __("Automatic renewal failed, patron has unpaid fines") + ""; span_style = "display: none"; span_class = "renewals-allowed"; } else if ( oObj.can_renew_error == "auto_account_expired" ) { msg += "" - + NOT_RENEWABLE_AUTO_ACCOUNT_EXPIRED + + __("Automatic renewal failed, account expired") + ""; span_style = "display: none"; span_class = "renewals-allowed"; } else if ( oObj.can_renew_error == "auto_renew" ) { msg += "" - + NOT_RENEWABLE_AUTO_RENEW + + __("Scheduled for automatic renewal") + ""; span_style = "display: none"; @@ -493,7 +493,7 @@ $(document).ready(function() { // Don't display something if it's an onsite checkout } else if ( oObj.can_renew_error == "item_denied_renewal" ) { content += "" - + NOT_RENEWABLE_DENIED + + __("Renewal denied by syspref") + ""; span_style = "display: none"; @@ -528,7 +528,7 @@ $(document).ready(function() { content += msg; if ( can_renew || can_force_renew ) { content += "(" - + RENEWALS_REMAINING.format( oObj.renewals_remaining, oObj.renewals_allowed ) + + __("%s of %s renewals remaining").format( oObj.renewals_remaining, oObj.renewals_allowed ) + ")"; } @@ -542,7 +542,7 @@ $(document).ready(function() { "bVisible": AllowCirculate ? true : false, "mDataProp": function ( oObj ) { if ( oObj.can_renew_error == "on_reserve" ) { - return "" + ON_HOLD + ""; + return "" + __("On hold") + ""; } else { return ""; } @@ -557,7 +557,7 @@ $(document).ready(function() { if ( oObj.return_claim_id ) { content = '' + oObj.return_claim_created_on_formatted + ''; } else { - content = '' + RETURN_CLAIMED_MAKE + ''; + content = '' + __("Claim returned") + ''; } return content; } @@ -601,9 +601,9 @@ $(document).ready(function() { "dataSrc": "issued_today", "startRender": function ( rows, group ) { if ( group ) { - return TODAYS_CHECKOUTS; + return __("Today's checkouts"); } else { - return PREVIOUS_CHECKOUTS; + return __("Previous checkouts"); } } }, @@ -616,13 +616,13 @@ $(document).ready(function() { var ul = $('