From 314e1cb4fb69438a6cd3889aa3d866aeb4f65738 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Fri, 16 Jun 2023 14:22:08 +0000 Subject: [PATCH] Bug 33983: Move translatable strings out of OPAC's datatables.inc into JavaScript This patch removes the definition of translatable strings out of the OPAC datatables.inc file and into datatables.js using the new JS i81n function. To test apply the patch and test some DataTable-driven tables in the OPAC. A list of possible examples: - Cart - Bibliographic detail page - Place hold (with OPAC item level holds enabled in circulation rules) - Show more options -> - A specific item - Bibliographic detail page for a serial record -> - More details -> - Full history - Most popular - Self checkout - Logged in user -> - Charges - Curbside pickups - Messaging - Checkout history - Suggestions - Holds history - Tags - Recalls history - Search history - ILL requests DataTables functionality should be unaffected. Check that the strings defined for translation are still working. For instance the "Clear filter" label on user summary checkouts, or the "No matching records found" text displayed when you search a table for a string that doesn't exist. TESTING TRANSLATABILITY - Update a translation, e.g. fr-FR: > cd misc/translator > perl translate update fr-FR - Open the corresponding .po file for JavaScript strings, in this case misc/translator/po/fr-FR-messages-js.po - Locate strings pulled from koha-tmpl/intranet-tmpl/prog/js/members.js for translation, e.g.: msgid "Clear filter" - Edit the corresponding "msgstr" string however you want (it's just for testing). - Install the updated translation: > perl translate install fr-FR - Switch to your newly translated language and repeat the test plan above. The translated strings should appear. Signed-off-by: David Nind Signed-off-by: Katrin Fischer --- .../bootstrap/en/includes/datatables.inc | 22 ---------- .../opac-tmpl/bootstrap/js/datatables.js | 40 +++++++++---------- 2 files changed, 20 insertions(+), 42 deletions(-) diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/datatables.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/datatables.inc index 91a6f1ccb1..23f98c23c0 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/datatables.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/datatables.inc @@ -2,26 +2,4 @@ [% USE Asset %] [% Asset.js("lib/jquery/plugins/jquery.dataTables.min.js") | $raw %] [% Asset.js("lib/jquery/plugins/dataTables.responsive.min.js") | $raw %] - [% Asset.js("js/datatables.js") | $raw %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/js/datatables.js b/koha-tmpl/opac-tmpl/bootstrap/js/datatables.js index 776b3bbdc7..185df7b7b4 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/js/datatables.js +++ b/koha-tmpl/opac-tmpl/bootstrap/js/datatables.js @@ -8,26 +8,26 @@ var dataTablesDefaults = { "language": { "paginate": { - "first" : window.MSG_DT_FIRST || "First", - "last" : window.MSG_DT_LAST || "Last", - "next" : window.MSG_DT_NEXT || "Next", - "previous" : window.MSG_DT_PREVIOUS || "Previous" + "first" : __("First"), + "last" : __("Last"), + "next" : __("Next"), + "previous" : __("Previous") }, - "emptyTable" : window.MSG_DT_EMPTY_TABLE || "No data available in table", - "info" : window.MSG_DT_INFO || "Showing _START_ to _END_ of _TOTAL_ entries", - "infoEmpty" : window.MSG_DT_INFO_EMPTY || "No entries to show", - "infoFiltered" : window.MSG_DT_INFO_FILTERED || "(filtered from _MAX_ total entries)", - "lengthMenu" : window.MSG_DT_LENGTH_MENU || "Show _MENU_ entries", - "loadingRecords" : window.MSG_DT_LOADING_RECORDS || "Loading...", - "processing" : window.MSG_DT_PROCESSING || "Processing...", - "search" : window.MSG_DT_SEARCH || "Search:", - "zeroRecords" : window.MSG_DT_ZERO_RECORDS || "No matching records found", + "emptyTable" : __("No data available in table"), + "info" : __("Showing _START_ to _END_ of _TOTAL_ entries"), + "infoEmpty" : __("No entries to show"), + "infoFiltered" : __("(filtered from _MAX_ total entries)"), + "lengthMenu" : __("Show _MENU_ entries"), + "loadingRecords" : __("Loading..."), + "processing" : __("Processing..."), + "search" : __("Search:"), + "zeroRecords" : __("No matching records found"), buttons: { - "copyTitle" : window.MSG_DT_COPY_TO_CLIPBOARD || "Copy to clipboard", - "copyKeys" : window.MSG_DT_COPY_KEYS || "Press ctrl or + C to copy the table data
to your system clipboard.

To cancel, click this message or press escape.", + "copyTitle" : __("Copy to clipboard"), + "copyKeys" : __("Press ctrl or + C to copy the table data
to your system clipboard.

To cancel, click this message or press escape."), "copySuccess": { - _: window.MSG_DT_COPIED_ROWS || "Copied %d rows to clipboard", - 1: window.MSG_DT_COPIED_ONE_ROW || "Copied one row to clipboard", + _: __("Copied %d rows to clipboard"), + 1: __("Copied one row to clipboard"), }, "print": __("Print") } @@ -55,9 +55,9 @@ var dataTablesDefaults = { $.fn.dataTable.ext.buttons.clearFilter = { fade: 100, className: "dt_button_clear_filter", - titleAttr: window.MSG_CLEAR_FILTER, + titleAttr: __("Clear filter"), enabled: false, - text: ' ' + window.MSG_CLEAR_FILTER + '', + text: ' ' + __("Clear filter") + '', available: function ( dt ) { // The "clear filter" button is made available if this test returns true if( dt.settings()[0].aanFeatures.f ){ // aanFeatures.f is null if there is no search form @@ -85,7 +85,7 @@ $.fn.dataTable.ext.buttons.clearFilter = { * from a configuration file (in English, "a," "an," and "the") */ - var config_exclude_articles_from_sort = window.CONFIG_EXCLUDE_ARTICLES_FROM_SORT || "a an the"; + var config_exclude_articles_from_sort = __("a an the"); if (config_exclude_articles_from_sort){ var articles = config_exclude_articles_from_sort.split(" "); var rpattern = ""; -- 2.30.2