From d6f4d154ac9ec587c147ffe16de1140e861dd9ec Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Mon, 12 Jun 2023 16:30:59 +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 DataTable-driven tables in the OPAC. Affected pages: - 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. --- .../bootstrap/en/includes/datatables.inc | 22 ---------- .../bootstrap/en/modules/opac-account.tt | 1 + .../bootstrap/en/modules/opac-basket.tt | 1 + .../en/modules/opac-curbside-pickups.tt | 1 + .../bootstrap/en/modules/opac-detail.tt | 1 + .../en/modules/opac-full-serial-issues.tt | 1 + .../bootstrap/en/modules/opac-holdshistory.tt | 1 + .../bootstrap/en/modules/opac-illrequests.tt | 1 + .../bootstrap/en/modules/opac-messaging.tt | 1 + .../en/modules/opac-readingrecord.tt | 1 + .../bootstrap/en/modules/opac-recalls.tt | 1 + .../bootstrap/en/modules/opac-reserve.tt | 1 + .../en/modules/opac-search-history.tt | 1 + .../bootstrap/en/modules/opac-suggestions.tt | 1 + .../bootstrap/en/modules/opac-tags.tt | 1 + .../bootstrap/en/modules/opac-topissues.tt | 1 + .../bootstrap/en/modules/opac-user.tt | 1 + .../bootstrap/en/modules/sco/sco-main.tt | 1 + .../opac-tmpl/bootstrap/js/datatables.js | 40 +++++++++---------- 19 files changed, 37 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/en/modules/opac-account.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-account.tt index adf358c116..661d5c9e26 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-account.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-account.tt @@ -6,6 +6,7 @@ [% USE Price %] [% SET ENABLE_OPAC_PAYMENTS = payment_methods %] [% USE AdditionalContents %] +[% PROCESS 'i18n.inc' %] [% SET DISPLAY_PAYMENT_BLOCK = 0 %] [% SET OpacNav = AdditionalContents.get( location => "OpacNav", lang => lang, library => logged_in_user.branchcode || default_branch, blocktitle => 0 ) %] [% SET OpacNavBottom = AdditionalContents.get( location => "OpacNavBottom", lang => lang, library => logged_in_user.branchcode || default_branch, blocktitle => 0 ) %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-basket.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-basket.tt index 7b20dad9c3..86bb7f5a78 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-basket.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-basket.tt @@ -4,6 +4,7 @@ [% USE Branches %] [% USE KohaDates %] [% USE Asset %] +[% PROCESS 'i18n.inc' %] [% SET is_popup = 1 %] [% SET TagsInputEnabled = ( ( Koha.Preference( 'opacuserlogin' ) == 1 ) && TagsEnabled && TagsInputOnList ) %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-curbside-pickups.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-curbside-pickups.tt index 2eb281fd04..6cab90f3c1 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-curbside-pickups.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-curbside-pickups.tt @@ -4,6 +4,7 @@ [% USE KohaDates %] [% USE Branches %] [% USE AdditionalContents %] +[% PROCESS 'i18n.inc' %] [% SET OpacNav = AdditionalContents.get( location => "OpacNav", lang => lang, library => logged_in_user.branchcode || default_branch, blocktitle => 0 ) %] [% SET OpacNavBottom = AdditionalContents.get( location => "OpacNavBottom", lang => lang, library => logged_in_user.branchcode || default_branch, blocktitle => 0 ) %] [% INCLUDE 'doc-head-open.inc' %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt index 36db7ae49c..ee6d19de49 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt @@ -7,6 +7,7 @@ [% USE TablesSettings %] [% USE AuthorisedValues %] [% USE KohaPlugins %] +[% PROCESS 'i18n.inc' %] [% SET TagsShowEnabled = ( ( Koha.Preference( 'TagsEnabled' ) == 1 ) && TagsShowOnDetail ) %] [% SET TagsInputEnabled = ( ( Koha.Preference( 'opacuserlogin' ) == 1 ) && ( Koha.Preference( 'TagsEnabled' ) == 1 ) && TagsInputOnDetail ) %] [% SET CoverImagePlugins = KohaPlugins.get_plugins_opac_cover_images %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-full-serial-issues.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-full-serial-issues.tt index 758dfcbeec..61e0eacbd2 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-full-serial-issues.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-full-serial-issues.tt @@ -2,6 +2,7 @@ [% USE KohaDates %] [% USE Branches %] [% USE AdditionalContents %] +[% PROCESS 'i18n.inc' %] [% SET OpacNav = AdditionalContents.get( location => "OpacNav", lang => lang, library => logged_in_user.branchcode || default_branch, blocktitle => 0 ) %] [% SET OpacNavBottom = AdditionalContents.get( location => "OpacNavBottom", lang => lang, library => logged_in_user.branchcode || default_branch, blocktitle => 0 ) %] [% USE AuthorisedValues %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-holdshistory.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-holdshistory.tt index 8171142628..1c029a80eb 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-holdshistory.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-holdshistory.tt @@ -5,6 +5,7 @@ [% USE TablesSettings %] [% USE ItemTypes %] [% USE AdditionalContents %] +[% PROCESS 'i18n.inc' %] [% SET OpacNav = AdditionalContents.get( location => "OpacNav", lang => lang, library => logged_in_user.branchcode || default_branch, blocktitle => 0 ) %] [% SET OpacNavBottom = AdditionalContents.get( location => "OpacNavBottom", lang => lang, library => logged_in_user.branchcode || default_branch, blocktitle => 0 ) %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-illrequests.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-illrequests.tt index 1ce9da4755..f8e3d71104 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-illrequests.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-illrequests.tt @@ -3,6 +3,7 @@ [% USE KohaDates %] [% USE Branches %] [% USE AdditionalContents %] +[% PROCESS 'i18n.inc' %] [% SET OpacNav = AdditionalContents.get( location => "OpacNav", lang => lang, library => logged_in_user.branchcode || default_branch, blocktitle => 0 ) %] [% SET OpacNavBottom = AdditionalContents.get( location => "OpacNavBottom", lang => lang, library => logged_in_user.branchcode || default_branch, blocktitle => 0 ) %] [% INCLUDE 'doc-head-open.inc' %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-messaging.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-messaging.tt index cf3dd4c555..9430ba4fa1 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-messaging.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-messaging.tt @@ -1,5 +1,6 @@ [% USE Koha %] [% USE AdditionalContents %] +[% PROCESS 'i18n.inc' %] [% SET OpacNav = AdditionalContents.get( location => "OpacNav", lang => lang, library => logged_in_user.branchcode || default_branch, blocktitle => 0 ) %] [% SET OpacNavBottom = AdditionalContents.get( location => "OpacNavBottom", lang => lang, library => logged_in_user.branchcode || default_branch, blocktitle => 0 ) %] [% INCLUDE 'doc-head-open.inc' %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-readingrecord.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-readingrecord.tt index 528e6bc836..45f10a7dab 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-readingrecord.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-readingrecord.tt @@ -5,6 +5,7 @@ [% USE AdditionalContents %] [% USE Asset %] [% USE Price %] +[% PROCESS 'i18n.inc' %] [% SET OpacNav = AdditionalContents.get( location => "OpacNav", lang => lang, library => logged_in_user.branchcode || default_branch, blocktitle => 0 ) %] [% SET OpacNavBottom = AdditionalContents.get( location => "OpacNavBottom", lang => lang, library => logged_in_user.branchcode || default_branch, blocktitle => 0 ) %] [% INCLUDE 'doc-head-open.inc' %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-recalls.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-recalls.tt index c523cc9fda..80992e51e2 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-recalls.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-recalls.tt @@ -1,5 +1,6 @@ [% USE Koha %] [% USE KohaDates %] +[% PROCESS 'i18n.inc' %] [% INCLUDE 'doc-head-open.inc' %] Your recalls history › [% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog [% INCLUDE 'doc-head-close.inc' %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt index 2109a26fd6..0f941c391f 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt @@ -4,6 +4,7 @@ [% USE Price %] [% USE ItemTypes %] [% USE AuthorisedValues %] +[% PROCESS 'i18n.inc' %] [% INCLUDE 'doc-head-open.inc' %] Placing a hold › [% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog [% INCLUDE 'doc-head-close.inc' %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-search-history.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-search-history.tt index 4a9fab692a..0491c56fb8 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-search-history.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-search-history.tt @@ -3,6 +3,7 @@ [% USE Koha %] [% USE KohaDates %] [% USE AdditionalContents %] +[% PROCESS 'i18n.inc' %] [% SET OpacNav = AdditionalContents.get( location => "OpacNav", lang => lang, library => logged_in_user.branchcode || default_branch, blocktitle => 0 ) %] [% SET OpacNavBottom = AdditionalContents.get( location => "OpacNavBottom", lang => lang, library => logged_in_user.branchcode || default_branch, blocktitle => 0 ) %] [% INCLUDE 'doc-head-open.inc' %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt index 9c21008640..2a1f814d21 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt @@ -5,6 +5,7 @@ [% USE AuthorisedValues %] [% USE KohaDates %] [% USE AdditionalContents %] +[% PROCESS 'i18n.inc' %] [% SET opacsuggestion = AdditionalContents.get( location => "OpacSuggestioninstructions", lang => lang, library => logged_in_user.branchcode || default_branch ) %] [% SET OpacNav = AdditionalContents.get( location => "OpacNav", lang => lang, library => logged_in_user.branchcode || default_branch, blocktitle => 0 ) %] [% SET OpacNavBottom = AdditionalContents.get( location => "OpacNavBottom", lang => lang, library => logged_in_user.branchcode || default_branch, blocktitle => 0 ) %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-tags.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-tags.tt index 60319529e6..a7d2445082 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-tags.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-tags.tt @@ -2,6 +2,7 @@ [% USE Koha %] [% USE KohaDates %] [% USE AdditionalContents %] +[% PROCESS 'i18n.inc' %] [% SET OpacNav = AdditionalContents.get( location => "OpacNav", lang => lang, library => logged_in_user.branchcode || default_branch, blocktitle => 0 ) %] [% SET OpacNavBottom = AdditionalContents.get( location => "OpacNavBottom", lang => lang, library => logged_in_user.branchcode || default_branch, blocktitle => 0 ) %] [% INCLUDE 'doc-head-open.inc' %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-topissues.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-topissues.tt index 6c4b668be8..8a2c3daa80 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-topissues.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-topissues.tt @@ -3,6 +3,7 @@ [% USE AuthorisedValues %] [% USE ItemTypes %] [% USE AdditionalContents %] +[% PROCESS 'i18n.inc' %] [% SET OpacNav = AdditionalContents.get( location => "OpacNav", lang => lang, library => logged_in_user.branchcode || default_branch, blocktitle => 0 ) %] [% SET OpacNavBottom = AdditionalContents.get( location => "OpacNavBottom", lang => lang, library => logged_in_user.branchcode || default_branch, blocktitle => 0 ) %] [% INCLUDE 'doc-head-open.inc' %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt index b6028314e8..c41fd00ee8 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt @@ -7,6 +7,7 @@ [% USE Price %] [% USE AuthorisedValues %] [% USE AdditionalContents %] +[% PROCESS 'i18n.inc' %] [% SET OpacNav = AdditionalContents.get( location => "OpacNav", lang => lang, library => logged_in_user.branchcode || default_branch, blocktitle => 0 ) %] [% SET OpacNavBottom = AdditionalContents.get( location => "OpacNavBottom", lang => lang, library => logged_in_user.branchcode || default_branch, blocktitle => 0 ) %] [% SET OpacMySummaryNote = AdditionalContents.get( location => "OpacMySummaryNote", lang => lang, library => branchcode ) %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/sco/sco-main.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/sco/sco-main.tt index 003c792402..2c939d8e89 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/sco/sco-main.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/sco/sco-main.tt @@ -5,6 +5,7 @@ [% USE AudioAlerts %] [% USE To %] [% USE Price %] +[% PROCESS 'i18n.inc' %] [% INCLUDE 'doc-head-open.inc' %] Self checkout › [% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha [% END %] 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