Bug 12150 - Use more javascript string formatting in intranet for translated strings.
authorPasi Kallinen <pasi.kallinen@pttk.fi>
Mon, 28 Apr 2014 05:27:38 +0000 (08:27 +0300)
committerTomas Cohen Arazi <tomascohen@gmail.com>
Thu, 3 Jul 2014 12:52:48 +0000 (09:52 -0300)
http://bugs.koha-community.org/show_bug.cgi?id=12150

Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>

No bug number on description
No commit message
No test plan
No koha-qa errors

I only signed this because it's useful for translations
but we can live without it, so is up to QA now

Tested some easy messages (e.g. syspref saving), and
updated PO files to check new strings.
Inspected the code, I think that there are no errors.

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>

12 files changed:
koha-tmpl/intranet-tmpl/prog/en/includes/doc-head-close.inc
koha-tmpl/intranet-tmpl/prog/en/includes/merge-record-strings.inc
koha-tmpl/intranet-tmpl/prog/en/js/basket.js
koha-tmpl/intranet-tmpl/prog/en/js/datatables.js
koha-tmpl/intranet-tmpl/prog/en/js/members.js
koha-tmpl/intranet-tmpl/prog/en/js/merge-record.js
koha-tmpl/intranet-tmpl/prog/en/js/pages/preferences.js
koha-tmpl/intranet-tmpl/prog/en/js/xmlControlfield.js
koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences.tt
koha-tmpl/intranet-tmpl/prog/en/modules/circ/offline.tt
koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt
koha-tmpl/intranet-tmpl/prog/en/modules/tools/marc_modification_templates.tt

index 11f6f38..f6269de 100644 (file)
         var MSG_BASKET_EMPTY = _("Your cart is currently empty");
         var MSG_RECORD_IN_BASKET = _("This item is already in your cart");
         var MSG_RECORD_ADDED = _("This item has been added to your cart");
-        var MSG_NRECORDS_ADDED = _(" item(s) added to your cart");
-        var MSG_NRECORDS_IN_BASKET = _("already in your cart");
+        var MSG_NRECORDS_ADDED = _("%s item(s) added to your cart");
+        var MSG_NRECORDS_IN_BASKET = _("%s already in your cart");
         var MSG_NO_RECORD_SELECTED = _("No item was selected");
-        var MSG_NO_RECORD_ADDED = _("No item was added to your cart");
+        var MSG_NO_RECORD_ADDED = _("No item was added to your cart (already in your cart) !");
         var MSG_CONFIRM_DEL_BASKET = _("Are you sure you want to empty your cart?");
         var MSG_CONFIRM_DEL_RECORDS = _("Are you sure you want to remove the selected items?");
-        var MSG_IN_YOUR_CART = _("Items in your cart: ");
+        var MSG_IN_YOUR_CART = _("Items in your cart: %s");
         var MSG_NON_RESERVES_SELECTED = _("One or more selected items cannot be reserved.");
     //]]>
     </script>
index 822d4b5..6b04e54 100644 (file)
@@ -1,6 +1,5 @@
 [%# transletable strings for merge-record.js %]
 <script type="text/javascript">
     var MSG_MERGEREC_ALREADY_EXISTS = _("The field is non-repeatable and already exists in the destination record. Therefore, you cannot add it.");
-    var MSG_MERGEREC_SUBFIELD_PRE   = _("This subfield cannot be added: there is no");
-    var MSG_MERGEREC_SUBFIELD_POST  = _("field in the destination record.");
+    var MSG_MERGEREC_SUBFIELD   = _("This subfield cannot be added: there is no %s field in the destination record.");
 </script>
\ No newline at end of file
index 6dd9c0d..4086385 100644 (file)
@@ -184,10 +184,11 @@ function addSelRecords(valSel) { // function for adding a selection of biblios t
     var msg = "";
     if (nbAdd) {
         if (i > nbAdd) {
-            msg = nbAdd+" "+MSG_NRECORDS_ADDED+", "+(i-nbAdd)+" "+MSG_NRECORDS_IN_BASKET;
+            msg = MSG_NRECORDS_ADDED.format(nbAdd);
+            msg += MSG_NRECORDS_IN_BASKET.format((i-nbAdd));
         }
         else {
-            msg = nbAdd+" "+MSG_NRECORDS_ADDED;
+            msg = MSG_NRECORDS_ADDED.format(nbAdd);
         }
     }
     else {
@@ -195,7 +196,7 @@ function addSelRecords(valSel) { // function for adding a selection of biblios t
             msg = MSG_NO_RECORD_SELECTED;
         }
         else {
-            msg = MSG_NO_RECORD_ADDED+" ("+MSG_NRECORDS_IN_BASKET+") !";
+            msg = MSG_NO_RECORD_ADDED;
         }
     }
        showCartUpdate(msg);
@@ -378,10 +379,10 @@ function showLess() {
 function updateBasket(updated_value,target) {
        if(target){
        target.$('#basketcount').html(" <span>("+updated_value+")</span>");
-    target.$('#cartDetails').html(MSG_IN_YOUR_CART+updated_value);
+    target.$('#cartDetails').html(MSG_IN_YOUR_CART.format(updated_value));
        } else {
        $('#basketcount').html(" <span>("+updated_value+")</span>");
-    $('#cartDetails').html(MSG_IN_YOUR_CART+updated_value);
+    $('#cartDetails').html(MSG_IN_YOUR_CART.format(updated_value));
        }
        var basketcount = updated_value;
 }
index ec07acb..c1224f0 100644 (file)
@@ -232,14 +232,14 @@ function replace_html( original_node, type ) {
             replace_html_date( original_node, id, format );
             break;
         default:
-            alert("_(This node can't be replaced)");
+            alert(_("This node can't be replaced"));
     }
 }
 
 // Replace a node with a "From [date] To [date]" element
 // Used on tfoot > td
 function replace_html_date( original_node, id, format ) {
-    var node = $('<span style="white-space:nowrap">' + _("From") + '<input type="text" id="' + id + 'from" readonly="readonly" placeholder=\'' + _("Pick date") + '\' size="7" /><a title="Delete this filter" style="cursor:pointer" onclick=\'$("#' + id + 'from").val("").change();\' >&times;</a></span><br/><span style="white-space:nowrap">' + _("To") + '<input type="text" id="' + id + 'to" readonly="readonly" placeholder=\'' + _("Pick date") + '\' size="7" /><a title="Delete this filter" style="cursor:pointer" onclick=\'$("#' + id + 'to").val("").change();\' >&times;</a></span>');
+    var node = $('<span style="white-space:nowrap">' + _("From") + '<input type="text" id="' + id + 'from" readonly="readonly" placeholder=\'' + _("Pick date") + '\' size="7" /><a title="' + _("Delete this filter") + '" style="cursor:pointer" onclick=\'$("#' + id + 'from").val("").change();\' >&times;</a></span><br/><span style="white-space:nowrap">' + _("To") + '<input type="text" id="' + id + 'to" readonly="readonly" placeholder=\'' + _("Pick date") + '\' size="7" /><a title="' + _("Delete this filter") + '" style="cursor:pointer" onclick=\'$("#' + id + 'to").val("").change();\' >&times;</a></span>');
     $(original_node).replaceWith(node);
     var script = document.createElement( 'script' );
     script.type = 'text/javascript';
index d7c2947..44ea578 100644 (file)
@@ -8,7 +8,7 @@ if (d!=="") {
       var ok=1;
       var msg;
       if ( (date.length < 2) && (ok==1) ) {
-        msg = MSG_SEPARATOR+field.name;
+        msg = MSG_SEPARATOR.format(field.name);
         alert(msg); ok=0; field.focus();
         return;
       }
@@ -17,19 +17,19 @@ if (d!=="") {
       var yyyy = date[2];
       // checking days
       if ( ((isNaN(dd))||(dd<1)||(dd>31)) && (ok==1) ) {
-        msg = MSG_INCORRECT_DAY+field.name;
+        msg = MSG_INCORRECT_DAY.format(field.name);
         alert(msg); ok=0; field.focus();
         return false;
       }
       // checking months
       if ( ((isNaN(mm))||(mm<1)||(mm>12)) && (ok==1) ) {
-        msg = MSG_INCORRECT_MONTH+field.name;
+        msg = MSG_INCORRECT_MONTH.format(field.name);
         alert(msg); ok=0; field.focus();
         return false;
       }
       // checking years
       if ( ((isNaN(yyyy))||(yyyy<amin)||(yyyy>amax)) && (ok==1) ) {
-        msg = MSG_INCORRECT_YEAR+field.name;
+        msg = MSG_INCORRECT_YEAR.format(field.name);
         alert(msg); ok=0; field.focus();
         return false;
       }
index 3686a0e..bf1f13a 100644 (file)
@@ -91,7 +91,7 @@ function toggleField(pField) {
                         // We select the whole field and removing non-selected subfields, instead of...
 
                         // Alerting the user
-                        alert(MSG_MERGEREC_SUBFIELD_PRE + " " + field + " " + MSG_MERGEREC_SUBFIELD_POST);
+                        alert(MSG_MERGEREC_SUBFIELD.format(field));
                         pField.checked = false;
                     } else {
                         $(where).nextAll("ul").append(clone);
index 80b8429..6932312 100644 (file)
@@ -8,7 +8,7 @@ KOHA.Preferences = {
             humanMsg.displayAlert( MSG_NOTHING_TO_SAVE );
             return;
         }
-        KOHA.AJAX.MarkRunning( $( form ).find( '.save-all' ), _( MSG_SAVING ) );
+        KOHA.AJAX.MarkRunning( $( form ).find( '.save-all' ), MSG_SAVING );
         KOHA.AJAX.Submit( {
             data: data,
             url: '/cgi-bin/koha/svc/config/systempreferences/',
@@ -21,7 +21,7 @@ KOHA.Preferences = {
         modified_prefs.each(function(){
             var modified_pref = $(this).attr("id");
             modified_pref = modified_pref.replace("pref_","");
-            msg += "<strong>"+ MSG_SAVED_PREFERENCE + " " + modified_pref + "</strong>\n";
+            msg += "<strong>"+ MSG_SAVED_PREFERENCE.format(modified_pref) + "</strong>\n";
         });
         humanMsg.displayAlert(msg);
 
index 89e8e97..d995bda 100644 (file)
@@ -212,7 +212,7 @@ function changeH4Result(form, h4_result, tr_result, pos, value)
             }).responseXML;
             if (this.xmlDoc) this.renderTemplate();
             $("*").ajaxError(function(evt, request, settings){
-                alert(_("AJAX error: receiving data from ") + settings.url);
+                alert(_("AJAX error: receiving data from %s").format(settings.url));
             });
         },//loadXmlValues
 
index 63ecaaf..6b77990 100644 (file)
@@ -18,7 +18,7 @@
     var search_jumped = [% IF ( search_jumped ) %]true[% ELSE %]false[% END %];
     var MSG_NOTHING_TO_SAVE = _("Nothing to save");
     var MSG_SAVING = _("Saving...");
-    var MSG_SAVED_PREFERENCE = _("Saved preference");
+    var MSG_SAVED_PREFERENCE = _("Saved preference %s");
     var MSG_MODIFIED = _("modified");
     var MSG_MADE_CHANGES = _("You have made changes to system preferences.");
     var MSG_CLICK_TO_EXPAND = _("Click to expand this section");
index fe617c1..0a922a5 100644 (file)
 <script type="text/javascript">
 //<![CDATA[
 var ALERT_SUCCESSFUL_CHECKIN = _("Checked in item.");
-var ALERT_MATERIALS = _("Note about the accompanying materials: ");
+var ALERT_MATERIALS = _("Note about the accompanying materials: %s");
 var ALERT_RESTRICTED = _("Patron is RESTRICTED");
-var ALERT_NO_MATCHING_ITEM = _("No item with barcode in offline database (transaction recorded anyway): ");
+var ALERT_NO_MATCHING_ITEM = _("No item with barcode in offline database (transaction recorded anyway): %s");
 var ALERT_NOT_CHECKED_OUT = _("Item not listed as checked out in offline database (transaction recorded anyway)");
 var ALERT_ITEM_WITHDRAWN = _("Item has been withdrawn (transaction recorded anyway)");
 var ALERT_ITEM_RESTRICTED = _("Item is restricted (transaction recorded anyway)");
 var ALERT_ITEM_LOST = _("Item has been lost (transaction recorded anyway)");
-var ALERT_NO_MATCHING_PATRON = _("No patron cardnumber in offline database (proceeding anyway): ");
+var ALERT_NO_MATCHING_PATRON = _("No patron cardnumber in offline database (proceeding anyway): %s");
 var ALERT_PATRON_GONE_NO_ADDRESS = _("Patron's address is in doubt (proceeding anyway)");
 var ALERT_PATRON_CARD_LOST = _("Patron's card is lost");
-var ALERT_PATRON_EXPIRED = _("Patron's card is expired");
-var ALERT_PATRON_BLOCKED_TEMPORARY = _("Patron has had overdue items and is restricted until: ");
+var ALERT_PATRON_EXPIRED = _("Patron's card is expired (%s)");
+var ALERT_PATRON_BLOCKED_TEMPORARY = _("Patron has had overdue items and is restricted until: %s");
 var ALERT_PATRON_RESTRICTED = _("Patron is restricted");
-var ALERT_PATRON_FINE = _("Patron has outstanding fines: ");
-var ALERT_PATRON_FINE_OVER_LIMIT = _("Patron fines are over limit: ");
+var ALERT_PATRON_FINE = _("Patron has outstanding fines: %s");
+var ALERT_PATRON_FINE_OVER_LIMIT = _("Patron fines are over limit: %s");
 var UPLOAD_PENDING_MESSAGE = _("You have transactions in the offline circulation database on this computer that have not been uploaded.");
 var NO_UPLOAD_PENDING_MESSAGE = _("You do not have any pending transactions in the offline circulation database on this computer.");
 
@@ -79,10 +79,10 @@ function checkin(barcode, item, error) {
 function checkAlerts(barcode, item) {
     var alerts = [];
     if (typeof item === 'undefined') {
-        alerts.push(ALERT_NO_MATCHING_ITEM + barcode);
+        alerts.push(ALERT_NO_MATCHING_ITEM.format(barcode));
     } else {
         if (typeof item.materials !== 'undefined' && item.materials != null) {
-            alerts.push(ALERT_MATERIALS + item.materials);
+            alerts.push(ALERT_MATERIALS.format(item.materials));
         }
     }
     return alerts;
@@ -321,7 +321,7 @@ function recordFine(amount) {
 function checkPatronAlerts(cardnumber, patron) {
     var alerts = [];
     if (typeof patron === 'undefined') {
-        alerts.push(ALERT_NO_MATCHING_PATRON + cardnumber);
+        alerts.push(ALERT_NO_MATCHING_PATRON.format(cardnumber));
     } else {
         if (patron.gonenoaddress !== '0') {
             alerts.push(ALERT_PATRON_GONE_NO_ADDRESS);
@@ -331,18 +331,18 @@ function checkPatronAlerts(cardnumber, patron) {
         }
         if (patron.debarred !== null) {
             if (patron.debarred != '9999-12-31') {
-                alerts.push(ALERT_PATRON_BLOCKED_TEMPORARY + $.datepicker.formatDate(dateformat, new Date(patron.debarred)));
+                alerts.push(ALERT_PATRON_BLOCKED_TEMPORARY.format($.datepicker.formatDate(dateformat, new Date(patron.debarred))));
             } else {
                 alerts.push(ALERT_PATRON_RESTRICTED);
             }
         }
         if (new Date(patron.dateexpiry) < new Date()) {
-            alerts.push(ALERT_PATRON_EXPIRED + ' (' + $.datepicker.formatDate(dateformat, new Date(patron.dateexpiry)) + ')');
+            alerts.push(ALERT_PATRON_EXPIRED.format($.datepicker.formatDate(dateformat, new Date(patron.dateexpiry))));
         }
         if (parseInt(patron.fine) > [% maxoutstanding %]) {
-            alerts.push(ALERT_PATRON_FINE_OVER_LIMIT + patron.fine);
+            alerts.push(ALERT_PATRON_FINE_OVER_LIMIT.format(patron.fine));
         } else if (parseInt(patron.fine) > 0) {
-            alerts.push(ALERT_PATRON_FINE + patron.fine);
+            alerts.push(ALERT_PATRON_FINE.format(patron.fine));
         }
     }
     return alerts;
index 430543e..858f7f3 100644 (file)
         $(mytables).find(" li[data-category_code='']").show();
     }
 
-               var MSG_SEPARATOR = _("Separator must be / in field ");
-        var MSG_INCORRECT_DAY = _("Invalid day entered in field ");
-        var MSG_INCORRECT_MONTH = _("Invalid month entered in field ");
-        var MSG_INCORRECT_YEAR = _("Invalid year entered in field ");
+        var MSG_SEPARATOR = _("Separator must be / in field %s");
+        var MSG_INCORRECT_DAY = _("Invalid day entered in field %s");
+        var MSG_INCORRECT_MONTH = _("Invalid month entered in field %s");
+        var MSG_INCORRECT_YEAR = _("Invalid year entered in field %s");
         var MSG_DUPLICATE_PATRON = _("Warning: Duplicate patron");
         var MSG_DUPLICATE_ORGANIZATION = _("Warning: Duplicate organization");
         var MSG_LATE_EXPIRY = _("Warning: Expiration date falls before enrollment date");
index 871fa77..bcf3e56 100644 (file)
@@ -202,7 +202,7 @@ function editAction( mmta_id, ordering, action, field_number, from_field, from_s
     document.getElementById('description').value = description;
 
     window.modaction_legend_innerhtml = document.getElementById('modaction_legend').innerhtml;
-    document.getElementById('modaction_legend').innerhtml = _("Edit action") + ordering;
+    document.getElementById('modaction_legend').innerhtml = _("Edit action%s").format(ordering);
 
     window.action_submit_value = document.getElementById('action_submit').value;
     document.getElementById('action_submit').value = _("Update action");