Bugzilla – Attachment 106027 Details for
Bug 25321
Move translatable strings out of strings.inc into the corresponding JavaScript
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 25321: (Part 1) Move translatable strings out of strings.inc into checkouts.js
Bug-25321-Part-1-Move-translatable-strings-out-of-.patch (text/plain), 19.22 KB, created by
Owen Leonard
on 2020-06-18 16:55:00 UTC
(
hide
)
Description:
Bug 25321: (Part 1) Move translatable strings out of strings.inc into checkouts.js
Filename:
MIME Type:
Creator:
Owen Leonard
Created:
2020-06-18 16:55:00 UTC
Size:
19.22 KB
patch
obsolete
>From 07c7a2187106ed534ccb78a777e8f18068adc123 Mon Sep 17 00:00:00 2001 >From: Owen Leonard <oleonard@myacpl.org> >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 | 35 ---------- > koha-tmpl/intranet-tmpl/prog/js/checkouts.js | 74 +++++++++++----------- > 2 files changed, 37 insertions(+), 72 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..36c0ae4d05 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/strings.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/strings.inc >@@ -1,33 +1,7 @@ > <!-- strings.inc --> > <script> >- var CIRCULATION_RETURNED = _("Checked in"); >- var CIRCULATION_NOT_RETURNED = _("Unable to check in"); >- var NOT_RENEWABLE_OVERDUE = _("Not allowed: overdue"); >- var NOT_RENEWABLE_RESTRICTION = _("Not allowed: patron restricted"); >- var CIRCULATION_RENEWED_DUE = _("Renewed, due:"); >- var CIRCULATION_RENEW_FAILED = _("Renew failed:"); >- var RETURN_CLAIMED = _("Return claimed"); >- var RETURN_CLAIMED_FAILURE = _("Unable to claim as returned"); >- var RETURN_CLAIMED_MAKE = _("Claim returned"); >- var RETURN_CLAIMED_NOTES = _("Notes about return claim"); >- var NOT_CHECKED_OUT = _("not checked out"); >- var TOO_MANY_RENEWALS = _("too many renewals"); >- var ON_RESERVE = _("on hold"); >- var REASON_UNKNOWN = _("reason unknown"); >- var TODAYS_CHECKOUTS = _("Today's checkouts"); >- var PREVIOUS_CHECKOUTS = _("Previous checkouts"); > var BY = _("by _AUTHOR_"); >- var ON_HOLD = _("On hold"); > var PLACE_HOLD = _("Place hold"); >- var NOT_RENEWABLE = _("Not renewable"); >- var NOT_RENEWABLE_TOO_SOON = _("No renewal before %s"); >- var NOT_RENEWABLE_AUTO_TOO_SOON = _("Scheduled for automatic renewal"); >- var NOT_RENEWABLE_AUTO_TOO_LATE = _("Can no longer be auto-renewed - number of checkout days exceeded"); >- var NOT_RENEWABLE_AUTO_TOO_MUCH_OWEING = _("Automatic renewal failed, patron has unpaid fines"); >- var NOT_RENEWABLE_AUTO_ACCOUNT_EXPIRED = _("Automatic renewal failed, account expired"); >- var NOT_RENEWABLE_AUTO_RENEW = _("Scheduled for automatic renewal"); >- var NOT_RENEWABLE_DENIED = _("Renewal denied by syspref"); >- var RENEWALS_REMAINING = _("%s of %s renewals remaining"); > var HOLD_IS_SUSPENDED = _("Hold is <strong>suspended</strong>"); > var UNTIL = _("until %s"); > var NEXT_AVAILABLE_ITYPE = _("Next available %s item"); >@@ -35,11 +9,9 @@ > var ITEM_IS_WAITING_HERE = _("Item is <strong>waiting here</strong>"); > var AT = _("at %s"); > var ITEM_IS_IN_TRANSIT = _("Item is <strong>in transit</strong> from %s since %s"); >- var FROM = _("from"); > var NOT_TRANSFERRED_YET = _("Item hasn't been transferred yet from %s"); > var NO = _("No"); > var YES = _("Yes"); >- var INHOUSE_USE = _("On-site checkout"); > var CANCEL = _("Cancel"); > var RESUME = _("Resume"); > var SUSPEND = _("Suspend"); >@@ -50,12 +22,5 @@ > var SUSPEND_HOLD_ERROR_NOT_FOUND = _("Unable to suspend hold, hold not found"); > var RESUME_HOLD_ERROR_NOT_FOUND = _("Unable to resume, hold not found"); > var CURRENT = _(" (current) "); >- var MSG_NO_ITEMTYPE = _("No itemtype"); >- var MSG_CHECKOUTS_BY_ITEMTYPE = _("Number of checkouts by item type"); >- var PATRON_NOTE = _("Patron note"); >- var CONFIRM_DELETE_RETURN_CLAIM = _("Are you sure you want to delete this return claim?"); >- var BROWSER_RETURN_TO_SEARCH = _("Results"); >- var BROWSER_PREVIOUS = _("Previous"); >- var BROWSER_NEXT = _("Next"); > </script> > <!-- / strings.inc --> >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 "<strong>" + TODAYS_CHECKOUTS + "</strong>"; >+ return "<strong>" + __("Today's checkouts") + "</strong>"; > } else { >- return "<strong>" + PREVIOUS_CHECKOUTS + "</strong>"; >+ return "<strong>" + __("Previous checkouts") + "</strong>"; > } > } > }, >@@ -328,7 +328,7 @@ $(document).ready(function() { > > var onsite_checkout = ''; > if ( oObj.onsite_checkout == 1 ) { >- onsite_checkout += " <span class='onsite_checkout'>(" + INHOUSE_USE + ")</span>"; >+ onsite_checkout += " <span class='onsite_checkout'>(" + __("On-site checkout") + ")</span>"; > } > > title += " " >@@ -421,70 +421,70 @@ $(document).ready(function() { > // Do nothing > } else if ( oObj.can_renew_error == "on_reserve" ) { > msg += "<span>" >- + "<a href='/cgi-bin/koha/reserve/request.pl?biblionumber=" + oObj.biblionumber + "'>" + ON_HOLD + "</a>" >+ + "<a href='/cgi-bin/koha/reserve/request.pl?biblionumber=" + oObj.biblionumber + "'>" + __("On hold") + "</a>" > + "</span>"; > > span_style = "display: none"; > span_class = "renewals-allowed-on_reserve"; > } else if ( oObj.can_renew_error == "too_many" ) { > msg += "<span class='renewals-disabled'>" >- + NOT_RENEWABLE >+ + __("Not renewable") > + "</span>"; > > span_style = "display: none"; > span_class = "renewals-allowed"; > } else if ( oObj.can_renew_error == "restriction" ) { > msg += "<span class='renewals-disabled'>" >- + NOT_RENEWABLE_RESTRICTION >+ + __("Not allowed: patron restricted") > + "</span>"; > > span_style = "display: none"; > span_class = "renewals-allowed"; > } else if ( oObj.can_renew_error == "overdue" ) { > msg += "<span class='renewals-disabled'>" >- + NOT_RENEWABLE_OVERDUE >+ + __("Not allowed: overdue") > + "</span>"; > > span_style = "display: none"; > span_class = "renewals-allowed"; > } else if ( oObj.can_renew_error == "too_soon" ) { > msg += "<span class='renewals-disabled'>" >- + NOT_RENEWABLE_TOO_SOON.format( oObj.can_renew_date ) >+ + __("No renewal before %s").format( oObj.can_renew_date ) > + "</span>"; > > span_style = "display: none"; > span_class = "renewals-allowed"; > } else if ( oObj.can_renew_error == "auto_too_soon" ) { > msg += "<span class='renewals-disabled'>" >- + NOT_RENEWABLE_AUTO_TOO_SOON >+ + __("Scheduled for automatic renewal") > + "</span>"; > > span_style = "display: none"; > span_class = "renewals-allowed"; > } else if ( oObj.can_renew_error == "auto_too_late" ) { > msg += "<span class='renewals-disabled'>" >- + NOT_RENEWABLE_AUTO_TOO_LATE >+ + __("Can no longer be auto-renewed - number of checkout days exceeded") > + "</span>"; > > span_style = "display: none"; > span_class = "renewals-allowed"; > } else if ( oObj.can_renew_error == "auto_too_much_oweing" ) { > msg += "<span class='renewals-disabled'>" >- + NOT_RENEWABLE_AUTO_TOO_MUCH_OWEING >+ + __("Automatic renewal failed, patron has unpaid fines") > + "</span>"; > > span_style = "display: none"; > span_class = "renewals-allowed"; > } else if ( oObj.can_renew_error == "auto_account_expired" ) { > msg += "<span class='renewals-disabled'>" >- + NOT_RENEWABLE_AUTO_ACCOUNT_EXPIRED >+ + __("Automatic renewal failed, account expired") > + "</span>"; > > span_style = "display: none"; > span_class = "renewals-allowed"; > } else if ( oObj.can_renew_error == "auto_renew" ) { > msg += "<span class='renewals-disabled'>" >- + NOT_RENEWABLE_AUTO_RENEW >+ + __("Scheduled for automatic renewal") > + "</span>"; > > 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 += "<span class='renewals-disabled'>" >- + NOT_RENEWABLE_DENIED >+ + __("Renewal denied by syspref") > + "</span>"; > > span_style = "display: none"; >@@ -528,7 +528,7 @@ $(document).ready(function() { > content += msg; > if ( can_renew || can_force_renew ) { > content += "<span class='renewals'>(" >- + RENEWALS_REMAINING.format( oObj.renewals_remaining, oObj.renewals_allowed ) >+ + __("%s of %s renewals remaining").format( oObj.renewals_remaining, oObj.renewals_allowed ) > + ")</span>"; > } > >@@ -542,7 +542,7 @@ $(document).ready(function() { > "bVisible": AllowCirculate ? true : false, > "mDataProp": function ( oObj ) { > if ( oObj.can_renew_error == "on_reserve" ) { >- return "<a href='/cgi-bin/koha/reserve/request.pl?biblionumber=" + oObj.biblionumber + "'>" + ON_HOLD + "</a>"; >+ return "<a href='/cgi-bin/koha/reserve/request.pl?biblionumber=" + oObj.biblionumber + "'>" + __("On hold") + "</a>"; > } else { > return "<input type='checkbox' class='checkin' id='checkin_" + oObj.itemnumber + "' name='checkin' value='" + oObj.itemnumber +"'></input>"; > } >@@ -557,7 +557,7 @@ $(document).ready(function() { > if ( oObj.return_claim_id ) { > content = '<span class="badge">' + oObj.return_claim_created_on_formatted + '</span>'; > } else { >- content = '<a class="btn btn-default btn-xs claim-returned-btn" data-itemnumber="' + oObj.itemnumber + '"><i class="fa fa-exclamation-circle"></i>' + RETURN_CLAIMED_MAKE + '</a>'; >+ content = '<a class="btn btn-default btn-xs claim-returned-btn" data-itemnumber="' + oObj.itemnumber + '"><i class="fa fa-exclamation-circle"></i>' + __("Claim returned") + '</a>'; > } > 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 = $('<ul>'); > Object.keys(checkoutsByItype).sort().forEach(function (itype) { > var li = $('<li>') >- .append($('<strong>').html(itype || MSG_NO_ITEMTYPE)) >+ .append($('<strong>').html(itype || __("No itemtype"))) > .append(': ' + checkoutsByItype[itype]); > ul.append(li); > }) > $('<details>') > .addClass('checkouts-by-itemtype') >- .append($('<summary>').html(MSG_CHECKOUTS_BY_ITEMTYPE)) >+ .append($('<summary>').html( __("Number of checkouts by item type") )) > .append(ul) > .insertBefore(oSettings.nTableWrapper) > }, >@@ -702,7 +702,7 @@ $(document).ready(function() { > > var onsite_checkout = ''; > if ( oObj.onsite_checkout == 1 ) { >- onsite_checkout += " <span class='onsite_checkout'>(" + INHOUSE_USE + ")</span>"; >+ onsite_checkout += " <span class='onsite_checkout'>(" + __("On-site checkout") + ")</span>"; > } > > title += " " >@@ -866,7 +866,7 @@ $(document).ready(function() { > content = '<span class="badge">' + created_on.toLocaleDateString() + '</span>'; > $(id).parent().parent().addClass('ok'); > } else { >- content = RETURN_CLAIMED_FAILURE; >+ content = __("Unable to claim as returned"); > $(id).parent().parent().addClass('warn'); > } > >@@ -1048,7 +1048,7 @@ $(document).ready(function() { > > // Hanld return claim deletion > $('body').on('click', '.return-claim-tools-delete', function() { >- let confirmed = confirm(CONFIRM_DELETE_RETURN_CLAIM); >+ let confirmed = confirm(__("Are you sure you want to delete this return claim?")); > if ( confirmed ) { > let id = $(this).data('return-claim-id'); > >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 25321
:
106026
|
106027
|
109031
|
109858
|
109971
|
109984
|
110893
|
110906