From a30f9e3d657c0560885b71a209e2d5adca09c7e5 Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Mon, 28 Apr 2014 08:27:38 +0300 Subject: [PATCH] Bug 12150 - Use more javascript string formatting in intranet for translated strings. http://bugs.koha-community.org/show_bug.cgi?id=12150 Signed-off-by: Bernardo Gonzalez Kriegel 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 Signed-off-by: Tomas Cohen Arazi --- .../prog/en/includes/doc-head-close.inc | 8 +++--- .../prog/en/includes/merge-record-strings.inc | 3 +- koha-tmpl/intranet-tmpl/prog/en/js/basket.js | 11 ++++---- .../intranet-tmpl/prog/en/js/datatables.js | 4 +-- koha-tmpl/intranet-tmpl/prog/en/js/members.js | 8 +++--- .../intranet-tmpl/prog/en/js/merge-record.js | 2 +- .../prog/en/js/pages/preferences.js | 4 +-- .../prog/en/js/xmlControlfield.js | 2 +- .../prog/en/modules/admin/preferences.tt | 2 +- .../prog/en/modules/circ/offline.tt | 28 +++++++++---------- .../prog/en/modules/members/memberentrygen.tt | 8 +++--- .../tools/marc_modification_templates.tt | 2 +- 12 files changed, 41 insertions(+), 41 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/doc-head-close.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/doc-head-close.inc index 11f6f38221..f6269de8ad 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/doc-head-close.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/doc-head-close.inc @@ -36,13 +36,13 @@ 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."); //]]> diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/merge-record-strings.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/merge-record-strings.inc index 822d4b5735..6b04e54109 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/merge-record-strings.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/merge-record-strings.inc @@ -1,6 +1,5 @@ [%# transletable strings for merge-record.js %] \ No newline at end of file diff --git a/koha-tmpl/intranet-tmpl/prog/en/js/basket.js b/koha-tmpl/intranet-tmpl/prog/en/js/basket.js index 6dd9c0d202..4086385be6 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/js/basket.js +++ b/koha-tmpl/intranet-tmpl/prog/en/js/basket.js @@ -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(" ("+updated_value+")"); - target.$('#cartDetails').html(MSG_IN_YOUR_CART+updated_value); + target.$('#cartDetails').html(MSG_IN_YOUR_CART.format(updated_value)); } else { $('#basketcount').html(" ("+updated_value+")"); - $('#cartDetails').html(MSG_IN_YOUR_CART+updated_value); + $('#cartDetails').html(MSG_IN_YOUR_CART.format(updated_value)); } var basketcount = updated_value; } diff --git a/koha-tmpl/intranet-tmpl/prog/en/js/datatables.js b/koha-tmpl/intranet-tmpl/prog/en/js/datatables.js index ec07acb835..c1224f0fe9 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/js/datatables.js +++ b/koha-tmpl/intranet-tmpl/prog/en/js/datatables.js @@ -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 = $('' + _("From") + '×
' + _("To") + '×'); + var node = $('' + _("From") + '×
' + _("To") + '×'); $(original_node).replaceWith(node); var script = document.createElement( 'script' ); script.type = 'text/javascript'; diff --git a/koha-tmpl/intranet-tmpl/prog/en/js/members.js b/koha-tmpl/intranet-tmpl/prog/en/js/members.js index d7c29476f2..44ea578517 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/js/members.js +++ b/koha-tmpl/intranet-tmpl/prog/en/js/members.js @@ -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))||(yyyyamax)) && (ok==1) ) { - msg = MSG_INCORRECT_YEAR+field.name; + msg = MSG_INCORRECT_YEAR.format(field.name); alert(msg); ok=0; field.focus(); return false; } diff --git a/koha-tmpl/intranet-tmpl/prog/en/js/merge-record.js b/koha-tmpl/intranet-tmpl/prog/en/js/merge-record.js index 3686a0ecd3..bf1f13aac1 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/js/merge-record.js +++ b/koha-tmpl/intranet-tmpl/prog/en/js/merge-record.js @@ -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); diff --git a/koha-tmpl/intranet-tmpl/prog/en/js/pages/preferences.js b/koha-tmpl/intranet-tmpl/prog/en/js/pages/preferences.js index 80b84298bb..6932312ebc 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/js/pages/preferences.js +++ b/koha-tmpl/intranet-tmpl/prog/en/js/pages/preferences.js @@ -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 += ""+ MSG_SAVED_PREFERENCE + " " + modified_pref + "\n"; + msg += ""+ MSG_SAVED_PREFERENCE.format(modified_pref) + "\n"; }); humanMsg.displayAlert(msg); diff --git a/koha-tmpl/intranet-tmpl/prog/en/js/xmlControlfield.js b/koha-tmpl/intranet-tmpl/prog/en/js/xmlControlfield.js index 89e8e9780d..d995bda23f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/js/xmlControlfield.js +++ b/koha-tmpl/intranet-tmpl/prog/en/js/xmlControlfield.js @@ -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 diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences.tt index 63ecaafe6a..6b77990449 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences.tt @@ -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"); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/offline.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/offline.tt index fe617c19bb..0a922a50c0 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/offline.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/offline.tt @@ -17,21 +17,21 @@