From 9e9088049c343cc8676630cfd6a5cde7fa897f0f Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Thu, 24 Apr 2014 14:51:28 +0300 Subject: [PATCH] Bug 12138 - Use placeholders in translatable Javascript strings Currently translating Javascript strings with variables in them is hard, because the strings are created from separate parts. For example: _("Are you sure you want to delete the") + " " + count + " " + _("attached items?") This is translated in two different parts, and the translator cannot affect the place where the count-variable is. Now, if the javascript strings allowed placeholders, similar to how the template strings do, the above could be written as: _("Are you sure you want to delete the %s attached items?").format(count) This would make translation much easier. Attached patch adds a Javascript string formatter, and changes all the concatenated translatable JS strings used in intranet to use that. To test: 1) cd misc/translator 2) perl translate update xx-YY 3) grep ^msgid po/xx-YY-i-staff-t-prog-v-3006000.po | sort | uniq > xx-YY-pre 4) apply patch 5) perl translate update xx-YY 6) grep ^msgid po/xx-YY-i-staff-t-prog-v-3006000.po | sort | uniq > xx-YY-post 7) compare the files: diff -Nurd xx-YY-pre xx-yy-post | less should show the javascript strings that changed. 8) Test the UIs where the formatted js strings are used. Signed-off-by: Owen Leonard I tested *most* of the changed files. There were some instances where it wasn't clear to me how to trigger the warnings which were modified, especially tags/review.tt, admin/manage-marc-import.tt, and holidays.tt. Everything I was able to test worked correctly. Signed-off-by: Katrin Fischer Works nicely, no regressions found. Thx! Signed-off-by: Galen Charlton --- .../prog/en/includes/cat-toolbar.inc | 16 ++++++++-------- .../intranet-tmpl/prog/en/js/staff-global.js | 13 +++++++++++++ .../prog/en/modules/acqui/addorderiso2709.tt | 2 +- .../en/modules/acqui/aqbasketuser_search.tt | 2 +- .../prog/en/modules/acqui/booksellers.tt | 2 +- .../prog/en/modules/acqui/invoices.tt | 2 +- .../prog/en/modules/acqui/neworderempty.tt | 5 ++--- .../prog/en/modules/acqui/orderreceive.tt | 2 +- .../prog/en/modules/acqui/z3950_search.tt | 2 +- .../prog/en/modules/admin/biblio_framework.tt | 4 ++-- .../modules/admin/item_circulation_alerts.tt | 2 +- .../prog/en/modules/authorities/authorities.tt | 4 ++-- .../prog/en/modules/cataloguing/addbiblio.tt | 4 ++-- .../prog/en/modules/cataloguing/additem.tt | 2 +- .../value_builder/marc21_field_006.tt | 2 +- .../value_builder/marc21_field_008.tt | 2 +- .../modules/cataloguing/z3950_auth_search.tt | 2 +- .../en/modules/cataloguing/z3950_search.tt | 2 +- .../prog/en/modules/circ/offline.tt | 10 +++++----- .../prog/en/modules/labels/label-manage.tt | 6 +++--- .../prog/en/modules/members/pay.tt | 3 +-- .../prog/en/modules/patron_lists/lists.tt | 2 +- .../prog/en/modules/patroncards/edit-batch.tt | 4 ++-- .../en/modules/patroncards/image-manage.tt | 4 ++-- .../prog/en/modules/patroncards/manage.tt | 6 +++--- .../prog/en/modules/reserve/request.tt | 2 +- .../prog/en/modules/serials/serials-edit.tt | 2 +- .../en/modules/serials/subscription-add.tt | 6 ++---- .../prog/en/modules/tags/review.tt | 12 ++++++------ .../prog/en/modules/tools/holidays.tt | 8 ++++---- .../en/modules/tools/manage-marc-import.tt | 18 ++++++++---------- .../prog/en/modules/tools/modborrowers.tt | 2 +- .../prog/en/modules/tools/quotes-upload.tt | 10 +++++----- .../prog/en/modules/tools/quotes.tt | 2 +- 34 files changed, 87 insertions(+), 80 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc index f69a7cd5a4..a296dd16be 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc @@ -35,24 +35,24 @@ var countdeletedorders = [% countdeletedorders %]; var is_confirmed; if (count > 0){ - is_confirmed = alert( count + " " +_("item(s) are attached to this record. You must delete all items before deleting this record.") ); + is_confirmed = alert( _("%s item(s) are attached to this record. You must delete all items before deleting this record.").format(count) ); } else if (countorders > 0){ [% IF ( CAN_user_acquisition_order_manage ) %] - is_confirmed = confirm( _("Warning: This record is used in")+" "+ countorders + " " +_("order(s). Deleting it could cause serious issues on acquisition module. Are you sure you want to delete this record?") ); + is_confirmed = confirm( _("Warning: This record is used in %s order(s). Deleting it could cause serious issues on acquisition module. Are you sure you want to delete this record?").format(countorders) ); [% ELSE %] - is_confirmed = alert( countorders + " " +_("order(s) are using this record. You need order managing permissions to delete this record.") ); + is_confirmed = alert( _("%s order(s) are using this record. You need order managing permissions to delete this record.").format(countorders) ); [% END %] } else if (countdeletedorders > 0){ [% IF ( CAN_user_acquisition_order_manage ) %] - is_confirmed = confirm( countdeletedorders + " " +_("deleted order(s) are using this record. Are you sure you want to delete this record?") ); + is_confirmed = confirm( _("%s deleted order(s) are using this record. Are you sure you want to delete this record?").format(countdeletedorders) ); [% ELSE %] - is_confirmed = alert( countdeletedorders + " " +_("deleted order(s) are using this record. You need order managing permissions to delete this record.") ); + is_confirmed = alert( _("%s deleted order(s) are using this record. You need order managing permissions to delete this record.").format(countdeletedorders) ); [% END %] } else if ( holdcount > 0 ) { - is_confirmed = confirm( holdcount + " " + _("holds(s) for this record. Are you sure you want to delete this record?")); + is_confirmed = confirm( _("%s holds(s) for this record. Are you sure you want to delete this record?").format(holdcount) ); } else { is_confirmed = confirm(_("Are you sure you want to delete this record?")); } @@ -74,9 +74,9 @@ var holdcount = [% holdcount %]; if ( holdcount > 0 ) { - alert( holdcount + " " + _("hold(s) on this record. You must delete all holds before deleting all items.") ); + alert( _("%s hold(s) on this record. You must delete all holds before deleting all items.").format(holdcount) ); } else if ( count > 0 ) { - if( confirm( _("Are you sure you want to delete the") + " " + count + " " + _("attached items?") ) ) { + if( confirm( _("Are you sure you want to delete the %s attached items?").format(count) ) ) { window.location="/cgi-bin/koha/cataloguing/additem.pl?op=delallitems&biblionumber=[% biblionumber %]"; } else { return false; diff --git a/koha-tmpl/intranet-tmpl/prog/en/js/staff-global.js b/koha-tmpl/intranet-tmpl/prog/en/js/staff-global.js index 909d74c15d..c553a6da07 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/js/staff-global.js +++ b/koha-tmpl/intranet-tmpl/prog/en/js/staff-global.js @@ -3,6 +3,19 @@ if ( KOHA === undefined ) var KOHA = {}; function _(s) { return s; } // dummy function for gettext +// http://stackoverflow.com/questions/1038746/equivalent-of-string-format-in-jquery/5341855#5341855 +String.prototype.format = function() { return formatstr(this, arguments) } +function formatstr(str, col) { + col = typeof col === 'object' ? col : Array.prototype.slice.call(arguments, 1); + var idx = 0; + return str.replace(/%%|%s|%(\d+)\$s/g, function (m, n) { + if (m == "%%") { return "%"; } + if (m == "%s") { return col[idx++]; } + return col[n]; + }); +}; + + // http://stackoverflow.com/questions/14859281/select-tab-by-name-in-jquery-ui-1-10-0/16550804#16550804 $.fn.tabIndex = function () { return $(this).parent().find(this).index() - 1; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/addorderiso2709.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/addorderiso2709.tt index 577d555cfe..149d532313 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/addorderiso2709.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/addorderiso2709.tt @@ -34,7 +34,7 @@ if (total_errors > 0) { var alertString = _("Form not submitted because of the following problem(s)"); alertString += "\n------------------------------------------------------------------------------------\n"; - alertString += "\n- "+ total_errors + _(" mandatory fields empty (highlighted)"); + alertString += "\n- " + _("%s mandatory fields empty (highlighted)").format(total_errors); alert(alertString); return false; } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/aqbasketuser_search.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/aqbasketuser_search.tt index 9b7f52bebd..91ca7644a5 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/aqbasketuser_search.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/aqbasketuser_search.tt @@ -18,7 +18,7 @@ function add_user(borrowernumber, borrowername) { var p = window.opener; if(p.add_basket_user(borrowernumber, borrowername) < 0) { - alert(_("Borrower '" + borrowername + "' is already in the list.")); + alert(_("Borrower '%s' is already in the list.").format(borrowername)); } } //]]> diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/booksellers.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/booksellers.tt index e6527a5af3..546f597b44 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/booksellers.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/booksellers.tt @@ -31,7 +31,7 @@ $(document).ready(function() { }); $(".modal").on("show", function(){ var basket = $(this).data("basketno"); - var legend = _("Add order to basket") + " " + basket; + var legend = _("Add order to basket %s").format(basket); $(this).find("legend").html(legend); }); }); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoices.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoices.tt index 8f0c21d873..7bfef8ceb0 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoices.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoices.tt @@ -70,7 +70,7 @@ $(document).ready(function() { $('#merge_' + prop).val(invoice[prop]); }); if (invoice.closedate) { - $('#merge_status').text(_("Closed on " + invoice.closedate + "")); + $('#merge_status').text(_("Closed on %s").format(invoice.closedate)); } else { $('#merge_status').text(_("Open")); } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt index e1d9ad521a..6b825b982d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt @@ -60,8 +60,7 @@ function Check(ff) { if (totalExceedsBudget(ff.budget_id.value, ff.total.value ) ) { ok=1; - _alertString += "\n- " + _("Order total (") + ff.total.value + - _(") exceeds budget available (") + actTotal+")"; + _alertString += "\n- " + _("Order total (%s) exceeds budget available (%s)").format(ff.total.value, actTotal); } if ( ff.field_value ) { @@ -69,7 +68,7 @@ function Check(ff) { if (empty_item_mandatory > 0) { ok = 1; _alertString += - "\n- " + empty_item_mandatory + _(" item mandatory fields empty"); + "\n- " + _("%s item mandatory fields empty").format(empty_item_mandatory); } } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt index 6d2b3fa345..dc0beeccde 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt @@ -13,7 +13,7 @@ if (total_errors != 0) { var alertString = _("Form not submitted because of the following problem(s)"); alertString += "\n------------------------------------------------------------------------------------\n"; - alertString += "\n- "+ total_errors+_(" mandatory fields empty (highlighted)"); + alertString += "\n- " + _("%s mandatory fields empty (highlighted)").format(total_errors); alert(alertString); return false; } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/z3950_search.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/z3950_search.tt index 32d449ccc4..99096e5551 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/z3950_search.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/z3950_search.tt @@ -59,7 +59,7 @@ function validate_goto_page(){ return false; } else if(page < 1 || page > [% total_pages %] ) { - alert(_("The page should be a number between 1 and ") + [% total_pages %] + "."); + alert(_("The page should be a number between 1 and %s.").format([% total_pages %])); return false; } else { diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/biblio_framework.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/biblio_framework.tt index ec458b30e0..382c366e84 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/biblio_framework.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/biblio_framework.tt @@ -67,7 +67,7 @@ function Check(f) { var matches = new RegExp("\\?error_import_export=(.+)$").exec(window.location.search); if (matches && matches.length > 1) { - alert(_("Error importing the framework ") + decodeURIComponent(matches[1])); + alert(_("Error importing the framework %s").format(decodeURIComponent(matches[1]))); } $('input.input_import').change( function() { @@ -89,7 +89,7 @@ function Check(f) { if (/(?:\.csv|\.ods|\.xml)$/.test(obj.val())) { if (confirm(_("Do you really want to import the framework fields and subfields? This will overwrite the current configuration. For safety reasons please use the export option to make a backup"))) { var frameworkcode = $('#' + id + ' input:hidden[name=frameworkcode]').val(); - $('#importing_' + frameworkcode).find("span").html(_("Importing to framework:")+"" + frameworkcode + ". " +_("Importing from file:")+"" + obj.val().replace(new RegExp("^.+[/\\\\]"),"") + ""); + $('#importing_' + frameworkcode).find("span").html(_("Importing to framework: %s. Importing from file: %s").format("" + frameworkcode + "", "" + obj.val().replace(new RegExp("^.+[/\\\\]"),"") + "")); if (navigator.userAgent.toLowerCase().indexOf('msie') != -1) { var timestamp = new Date().getTime(); $('#importing_' + frameworkcode).find("img").attr('src', '[% interface %]/[% theme %]/img/loading-small.gif' + '?' +timestamp); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/item_circulation_alerts.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/item_circulation_alerts.tt index d4efbef064..ad451e110c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/item_circulation_alerts.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/item_circulation_alerts.tt @@ -45,7 +45,7 @@ $(function(){ var blocked = _("Blocked!"); var saving = _("Saving..."); var disabledForAll = _("Disabled for all"); - var disabledForCurrent = _("Disabled for") + ' ' + $branch; + var disabledForCurrent = _("Disabled for %s").format($branch); $('#branch_selector input:submit').hide(); $('#branch').change(function(){ diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/authorities.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/authorities.tt index e8afb184cb..b7dcbf7a9b 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/authorities.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/authorities.tt @@ -46,7 +46,7 @@ function AreMandatoriesNotOk(){ // alert (id_string); if( ! $("#" + id_string).val() ){ $("#" + id_string).attr('class','subfield_not_filled').focus(); - StrAlert += "\t* "+label[i]+_(" in tab ")+tab[i]+"\n"; + StrAlert += "\t* " + _("%s in tab %s").format(label[i], tab[i]) + "\n"; } } @@ -79,7 +79,7 @@ function AreMandatoriesNotOk(){ if(isempty){ flag = 1; - StrAlert += "\t* Field " + arr[0] + _(" is mandatory, at least one of its subfields must be filled") + "\n"; + StrAlert += "\t* " + _("Field %s is mandatory, at least one of its subfields must be filled.").format(arr[0]) + "\n"; } } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt index 01218b2edb..f446d6e744 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt @@ -258,7 +258,7 @@ function AreMandatoriesNotOk(){ if (tabflag[tagsubfieldid][0]==0){ var tag=tagsubfieldid.substr(0,3); var subfield=tagsubfieldid.substr(3,1); - StrAlert += "\t* "+_("tag ")+tag+_(" subfield ")+subfield+" "+tabflag[tagsubfieldid][1]+_(" in tab ")+tabflag[tagsubfieldid][2]+"\n"; + StrAlert += "\t* "+_("tag %s subfield %s %s in tab %s").format(tag, subfield, tabflag[tagsubfieldid][1], tabflag[tagsubfieldid][2]) + "\n"; //StrAlert += "\t* "+label[i]+_(" in tab ")+tab[i]+"\n"; flag=1; } @@ -308,7 +308,7 @@ function AreMandatoriesNotOk(){ if(isempty){ flag = 1; - StrAlert += _("\t* Field ") + arr[0] + _(" is mandatory, at least one of its subfields must be filled.") + "\n"; + StrAlert += "\t* " + _("Field %s is mandatory, at least one of its subfields must be filled.").format(arr[0]) + "\n"; } } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt index 2d7f4b5ab4..85a4486bad 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt @@ -64,7 +64,7 @@ function Check(f) { if (total_errors > 0) { var alertString2 = _("Form not submitted because of the following problem(s)"); alertString2 += "\n------------------------------------------------------------------------------------\n"; - alertString2 += "\n- "+ total_errors + _(" mandatory fields empty (highlighted)"); + alertString2 += "\n- " + _("%s mandatory fields empty (highlighted)").format(total_errors); alert(alertString2); return false; } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/marc21_field_006.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/marc21_field_006.tt index 37524ff238..4f2fe48e65 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/marc21_field_006.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/marc21_field_006.tt @@ -24,7 +24,7 @@ function changeTypeofMaterial(form) { - if (form.material_type.options[form.material_type.selectedIndex].value != "" && confirm(_("Show values for") +' \'' + form.material_type.options[form.material_type.selectedIndex].text + '\' ' +_("material type?"))) { + if (form.material_type.options[form.material_type.selectedIndex].value != "" && confirm(_("Show values for '%s' material type?").format(form.material_type.options[form.material_type.selectedIndex].text))) { objXmlControlField.setIdMaterial(form.material_type.options[form.material_type.selectedIndex].value); objXmlControlField.renderTemplate(); renderResult(tr_result, form.result.value, true); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/marc21_field_008.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/marc21_field_008.tt index 4a5b8f8072..5bb381b632 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/marc21_field_008.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/marc21_field_008.tt @@ -24,7 +24,7 @@ function changeTypeofMaterial(form) { - if (form.material_type.options[form.material_type.selectedIndex].value != "" && confirm(_("Show values for") + ' \'' + form.material_type.options[form.material_type.selectedIndex].text + '\' ' + _("material type?"))) { + if (form.material_type.options[form.material_type.selectedIndex].value != "" && confirm(_("Show values for '%s' material type?").format(form.material_type.options[form.material_type.selectedIndex].text))) { objXmlControlField.setIdMaterial(form.material_type.options[form.material_type.selectedIndex].value); objXmlControlField.renderTemplate(); renderResult(tr_result, form.result.value, true); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/z3950_auth_search.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/z3950_auth_search.tt index f60dba9b53..08ba74e7f2 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/z3950_auth_search.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/z3950_auth_search.tt @@ -68,7 +68,7 @@ function validate_goto_page(){ return false; } else if(page < 1 || page > [% total_pages %] ) { - alert(_("The page should be a number between 1 and ") + [% total_pages %] + "."); + alert(_("The page should be a number between 1 and %s.").format([% total_pages %])); return false; } else { diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/z3950_search.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/z3950_search.tt index b3123e3bd2..37b03dcd73 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/z3950_search.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/z3950_search.tt @@ -69,7 +69,7 @@ function validate_goto_page(){ return false; } else if(page < 1 || page > [% total_pages %] ) { - alert(_("The page should be a number between 1 and ") + [% total_pages %] + "."); + alert(_("The page should be a number between 1 and %s.").format([% total_pages %])); return false; } else { 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 49f443ea7e..fe617c19bb 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/offline.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/offline.tt @@ -119,7 +119,7 @@ function synchronize() { }).done(function (data) { if (data) { $('.loading-overlay').hide(); - alert(_("Please log in to Koha and try again. (Error: '" + data + "')")); + alert(_("Please log in to Koha and try again. (Error: '%s')").format(data)); } else { var uploadIter = $.indexedDB("koha").objectStore("transactions").each(uploadTransaction); uploadIter.done(function() { @@ -193,7 +193,7 @@ function finishedLoading() { function loadRecords(page) { [% IF (AllowOfflineCirculation) %] - $(".loading-overlay div").text(_("Loading page " + page + ", please wait...")); + $(".loading-overlay div").text(_("Loading page %s, please wait...").format(page)); $(".loading-overlay").show(); $.ajax({ type: "GET", @@ -378,7 +378,7 @@ function showPatron(barcode, patron, error) { if (patron.name.length > 0) { $('.patron-title').text(patron.name); } else { - $('.patron-title').text(_("Unrecognized patron") + " (" + barcode + ")"); + $('.patron-title').text(_("Unrecognized patron (%s)").format(barcode)); } if (patron.address.length > 0 || patron.address2.length > 0) { $('#patron-address-1').text(patron.address); @@ -403,12 +403,12 @@ function showPatron(barcode, patron, error) { $('#patron-email').html('' + _("No email stored.") + ''); } if (patron.categorycode.length > 0) { - $('#patron-category').text(_("Category: ") + patron.categorycode); + $('#patron-category').text(_("Category: %s").format(patron.categorycode)); } else { $('#patron-category').html('' + _("Category code unknown.") + ''); } if (patron.branchcode.length > 0) { - $('#patron-library').text(_("Home library: ") + patron.branchcode); + $('#patron-library').text(_("Home library: %s").format(patron.branchcode)); } else { $('#patron-library').html('' + _("Home library unknown.") + ''); } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-manage.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-manage.tt index 791bac0db7..a5b1845bc7 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-manage.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-manage.tt @@ -7,7 +7,7 @@ function DeleteConfirm() { var element_id = selected_layout("delete"); if (element_id>-1) { - var msg = "Are you sure you want to delete [% label_element %] " + element_id + "?" + var msg = _("Are you sure you want to delete %s %s?").format("[% label_element %]", element_id); var answer = confirm(msg); if (answer) { window.location = "/cgi-bin/koha/labels/label-manage.pl?op=delete&label_element=[% label_element %]&element_id=" + element_id; @@ -64,7 +64,7 @@ return(document.layouts.action[selected[0]].value); } else { - alert(_("Please select only one ")+"[% label_element %]"+_(" to")+op+"."); + alert(_("Please select only one %s to %s.").format("[% label_element %]", op)); return (-1); } } @@ -73,7 +73,7 @@ return(document.layouts.action.value); } }; - alert(_("Please select a ")+"[% label_element %]."); + alert(_("Please select a %s.").format("[% label_element %]")); return (-1); }; //]]> diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tt index 80d7785f0b..58a80fe8f6 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tt @@ -16,8 +16,7 @@ function enableCheckboxActions(){ $(document).ready(function(){ $('#pay-fines-form').preventDoubleFormSubmit(); $("#woall").click(function(event){ - var msg = _("Are you sure you want to write off %s in outstanding fines? This cannot be undone!"); - msg = msg.replace( "%s", "[% total | format('%.2f') %]" ); + var msg = _("Are you sure you want to write off %s in outstanding fines? This cannot be undone!").format( "[% total | format('%.2f') %]" ); var answer = confirm(msg); if (!answer){ event.preventDefault(); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/patron_lists/lists.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/patron_lists/lists.tt index ec8c2b496b..8be8035f2d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/patron_lists/lists.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/patron_lists/lists.tt @@ -16,7 +16,7 @@ }); function ConfirmDelete( list ) { - return confirm( _("Are you sure you want to delete the list ") + list + "?" ); + return confirm( _("Are you sure you want to delete the list %s?").format(list) ); } //]]> diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/edit-batch.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/edit-batch.tt index 60806f1756..0851936454 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/edit-batch.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/edit-batch.tt @@ -7,7 +7,7 @@