Bugzilla – Attachment 100147 Details for
Bug 24662
Remove global variables MSG_* from datatables.inc
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24662: Remove global variables MSG_* from datatables.inc
Bug-24662-Remove-global-variables-MSG-from-datatab.patch (text/plain), 13.81 KB, created by
Bernardo Gonzalez Kriegel
on 2020-03-04 18:42:42 UTC
(
hide
)
Description:
Bug 24662: Remove global variables MSG_* from datatables.inc
Filename:
MIME Type:
Creator:
Bernardo Gonzalez Kriegel
Created:
2020-03-04 18:42:42 UTC
Size:
13.81 KB
patch
obsolete
>From 5be808be4429b3269314c9845b2210f5db19ebd2 Mon Sep 17 00:00:00 2001 >From: Julian Maurice <julian.maurice@biblibre.com> >Date: Fri, 14 Feb 2020 10:44:39 +0100 >Subject: [PATCH] Bug 24662: Remove global variables MSG_* from datatables.inc > >Now that bug 21156 is pushed, we don't need to have global variables in >.inc or .tt files for translation in .js file. We can simply declare our >translatable strings where they are used. > >This patch removes all global variables used in DataTables configuration > >Test plan: >1. cd misc/translator && ./translate update fr-FR >2. Translate strings in misc/tranlator/po/fr-FR-messages-js.po >3. cd misc/translator && ./translate install fr-FR >4. Go to the staff interface, in english, and check that DataTables >tables are still working. You should check at least the following pages: > - catalogue/detail.pl > - circ/circulation.pl > - tools/quotes.pl > - tools/letter.pl >5. Switch to french and check again DataTables tables, and verify that > strings are translated > >This patch depends on bug 24661 > >Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com> >Tested using es-ES or de-DE (build compendium, update, translate, install) >cd misc/translator >msgcat --use-first -o de.po po/de-DE-*.po >./translate update de-DE >msgmerge de.po po/de-DE-messages-js.po -o - | msgattrib --no-obsolete -o po/de-DE-messages-js.po >./translate install de-DE > >DataTables works, and are translated. >There are some messages from qa-tools. >--- > .../prog/en/includes/datatables.inc | 24 ---------- > .../prog/en/modules/circ/circulation.tt | 1 - > .../prog/en/modules/tools/quotes.tt | 18 +------- > koha-tmpl/intranet-tmpl/prog/js/checkouts.js | 5 +- > koha-tmpl/intranet-tmpl/prog/js/datatables.js | 46 +++++++++---------- > koha-tmpl/intranet-tmpl/prog/js/letter.js | 4 +- > .../intranet-tmpl/prog/js/table_filters.js | 4 +- > 7 files changed, 31 insertions(+), 71 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/datatables.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/datatables.inc >index cf0043e545..a545868ce7 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/datatables.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/datatables.inc >@@ -2,28 +2,4 @@ > [% USE Asset %] > [% INCLUDE 'format_price.inc' %] > [% Asset.js("lib/datatables/datatables.min.js") | $raw %] >-<script> >- var MSG_DT_FIRST = _("First"); >- var MSG_DT_LAST = _("Last"); >- var MSG_DT_NEXT = _("Next"); >- var MSG_DT_PREVIOUS = _("Previous"); >- var MSG_DT_EMPTY_TABLE = _("No data available in table"); >- var MSG_DT_INFO = _("Showing _START_ to _END_ of _TOTAL_"); >- var MSG_DT_INFO_EMPTY = _("No entries to show"); >- var MSG_DT_INFO_FILTERED = _("(filtered from _MAX_ total entries)"); >- var MSG_DT_LENGTH_MENU = _("Show _MENU_ entries"); >- var MSG_DT_LOADING_RECORDS = _("Loading..."); >- var MSG_DT_PROCESSING = _("Processing..."); >- var MSG_DT_SEARCH = _("Search:"); >- var MSG_DT_ZERO_RECORDS = _("No matching records found"); >- var MSG_DT_ALL = _("All"); >- var CONFIG_EXCLUDE_ARTICLES_FROM_SORT = _("a an the"); >- var MSG_DT_COPY_TITLE = _("Copy to clipboard"); >- var MSG_DT_COPY_KEYS = _("Press ctrl or â + C to copy the table data<br>to your system clipboard.<br><br>To cancel, click this message or press escape."); >- var MSG_DT_COPY_SUCCESS_ONE = _("Copied one row to clipboard"); >- var MSG_DT_COPY_SUCCESS_X = _("Copied %d rows to clipboard"); >- var MSG_CLEAR_FILTER = _("Clear filter"); >- var MSG_ACTIVATE_FILTERS = _("Activate filters"); >- var MSG_DEACTIVATE_FILTERS = _("Deactivate filters"); >-</script> > [% Asset.js("js/datatables.js") | $raw %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >index 1eeb19e3af..e73477ec85 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >@@ -1031,7 +1031,6 @@ > var ClaimReturnedLostValue = "[% Koha.Preference('ClaimReturnedLostValue') | html %]"; > var ClaimReturnedChargeFee = "[% Koha.Preference('ClaimReturnedChargeFee') | html %]"; > var ClaimReturnedWarningThreshold = "[% Koha.Preference('ClaimReturnedWarningThreshold') | html %]"; >- var MSG_DT_LOADING_RECORDS = _("Loading... you may continue scanning."); > var interface = "[% interface | html %]"; > var theme = "[% theme | html %]"; > var borrowernumber = "[% patron.borrowernumber | html %]"; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/quotes.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/quotes.tt >index 6191b02037..bf910d229c 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/quotes.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/quotes.tt >@@ -90,23 +90,7 @@ > { "sWidth": "75%" }, > { "sWidth": "11%" }, > ], >- "oLanguage" : { >- "oPaginate": { >- "sFirst": MSG_DT_FIRST, >- "sLast": MSG_DT_LAST, >- "sNext": MSG_DT_NEXT, >- "sPrevious": MSG_DT_PREVIOUS, >- }, >- "sEmptyTable": MSG_DT_EMPTY_TABLE, >- "sInfo": MSG_DT_INFO, >- "sInfoEmpty": MSG_DT_INFO_EMPTY, >- "sInfoFiltered": MSG_DT_INFO_FILTERED, >- "sLengthMenu": MSG_DT_LENGTH_MENU, >- "sLoadingRecords": MSG_DT_LOADING_RECORDS, >- "sProcessing": MSG_DT_PROCESSING, >- "sSearch": MSG_DT_SEARCH, >- "sZeroRecords": MSG_DT_ZERO_RECORDS, >- }, >+ "oLanguage": dataTablesDefaults.oLanguage, > "fnPreDrawCallback": function(oSettings) { > return true; > }, >diff --git a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js b/koha-tmpl/intranet-tmpl/prog/js/checkouts.js >index 169bdc4e36..3900a151fc 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/checkouts.js >@@ -233,10 +233,11 @@ $(document).ready(function() { > $('#issues-table').show(); > $('#issues-table-actions').show(); > >+ var msg_loading = __('Loading... you may continue scanning.'); > issuesTable = KohaTable("issues-table", { > "oLanguage": { >- "sEmptyTable" : MSG_DT_LOADING_RECORDS, >- "sProcessing": MSG_DT_LOADING_RECORDS, >+ "sEmptyTable" : msg_loading, >+ "sProcessing": msg_loading, > }, > "bAutoWidth": false, > "dom": 'B<"clearfix">rt', >diff --git a/koha-tmpl/intranet-tmpl/prog/js/datatables.js b/koha-tmpl/intranet-tmpl/prog/js/datatables.js >index a31db0614d..10845eb8db 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/datatables.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/datatables.js >@@ -1,6 +1,5 @@ > // These default options are for translation but can be used > // for any other datatables settings >-// MSG_DT_* variables comes from datatables.inc > // To use it, write: > // $("#table_id").dataTable($.extend(true, {}, dataTableDefaults, { > // // other settings >@@ -8,26 +7,26 @@ > var dataTablesDefaults = { > "oLanguage": { > "oPaginate": { >- "sFirst" : window.MSG_DT_FIRST || "First", >- "sLast" : window.MSG_DT_LAST || "Last", >- "sNext" : window.MSG_DT_NEXT || "Next", >- "sPrevious" : window.MSG_DT_PREVIOUS || "Previous" >+ "sFirst" : __('First'), >+ "sLast" : __('Last'), >+ "sNext" : __('Next'), >+ "sPrevious" : __('Previous'), > }, >- "sEmptyTable" : window.MSG_DT_EMPTY_TABLE || "No data available in table", >- "sInfo" : window.MSG_DT_INFO || "Showing _START_ to _END_ of _TOTAL_ entries", >- "sInfoEmpty" : window.MSG_DT_INFO_EMPTY || "No entries to show", >- "sInfoFiltered" : window.MSG_DT_INFO_FILTERED || "(filtered from _MAX_ total entries)", >- "sLengthMenu" : window.MSG_DT_LENGTH_MENU || "Show _MENU_ entries", >- "sLoadingRecords" : window.MSG_DT_LOADING_RECORDS || "Loading...", >- "sProcessing" : window.MSG_DT_PROCESSING || "Processing...", >- "sSearch" : window.MSG_DT_SEARCH || "Search:", >- "sZeroRecords" : window.MSG_DT_ZERO_RECORDS || "No matching records found", >+ "sEmptyTable" : __('No data available in table'), >+ "sInfo" : __('Showing _START_ to _END_ of _TOTAL_ entries'), >+ "sInfoEmpty" : __('No entries to show'), >+ "sInfoFiltered" : __('(filtered from _MAX_ total entries)'), >+ "sLengthMenu" : __('Show _MENU_ entries'), >+ "sLoadingRecords" : __('Loading...'), >+ "sProcessing" : __('Processing...'), >+ "sSearch" : __('Search:'), >+ "sZeroRecords" : __('No matching records found'), > buttons: { >- "copyTitle" : window.MSG_DT_COPY_TITLE || "Copy to clipboard", >- "copyKeys" : window.MSG_DT_COPY_KEYS || "Press <i>ctrl</i> or <i>â</i> + <i>C</i> to copy the table data<br>to your system clipboard.<br><br>To cancel, click this message or press escape.", >+ "copyTitle" : __('Copy to clipboard'), >+ "copyKeys" : __('Press <i>ctrl</i> or <i>â</i> + <i>C</i> to copy the table data<br>to your system clipboard.<br><br>To cancel, click this message or press escape.'), > "copySuccess": { >- _: window.MSG_DT_COPY_SUCCESS_X || "Copied %d rows to clipboard", >- 1: window.MSG_DT_COPY_SUCCESS_ONE || "Copied one row to clipboard" >+ _: __('Copied %d rows to clipboard'), >+ 1: __('Copied one row to clipboard'), > } > } > }, >@@ -35,9 +34,9 @@ var dataTablesDefaults = { > "buttons": [{ > fade: 100, > className: "dt_button_clear_filter", >- titleAttr: MSG_CLEAR_FILTER, >+ titleAttr: __('Clear filter'), > enabled: false, >- text: '<i class="fa fa-lg fa-remove"></i> <span class="dt-button-text">' + MSG_CLEAR_FILTER + '</span>', >+ text: '<i class="fa fa-lg fa-remove"></i> <span class="dt-button-text">' + __('Clear filter') + '</span>', > 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 >@@ -49,7 +48,7 @@ var dataTablesDefaults = { > node.addClass("disabled"); > } > }], >- "aLengthMenu": [[10, 20, 50, 100, -1], [10, 20, 50, 100, window.MSG_DT_ALL || "All"]], >+ "aLengthMenu": [[10, 20, 50, 100, -1], [10, 20, 50, 100, __('All')]], > "iDisplayLength": 20, > initComplete: function( settings) { > var tableId = settings.nTable.id >@@ -356,8 +355,9 @@ jQuery.extend( jQuery.fn.dataTableExt.oSort, { > * from a configuration file (in English, "a," "an," and "the") > */ > >- if(CONFIG_EXCLUDE_ARTICLES_FROM_SORT){ >- var articles = CONFIG_EXCLUDE_ARTICLES_FROM_SORT.split(" "); >+ 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 = ""; > for(i=0;i<articles.length;i++){ > rpattern += "^" + articles[i] + " "; >diff --git a/koha-tmpl/intranet-tmpl/prog/js/letter.js b/koha-tmpl/intranet-tmpl/prog/js/letter.js >index f4824abab3..7f4cb2ef6d 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/letter.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/letter.js >@@ -1,7 +1,7 @@ > /* Variables defined in letter.tt: */ >-/* global _ module add_form copy_form no_op_set MSG_EMPTY_TITLE_AND_CONTENT MSG_EMPTY_TEMPLATES code MSG_CODE_EXISTS MSG_CODE_EXISTS_FOR_LIBRARY MSG_DT_LOADING_RECORDS MSG_NO_NOTICE_FOUND interface theme KohaTable columns_settings */ >+/* global _ module add_form copy_form no_op_set MSG_EMPTY_TITLE_AND_CONTENT MSG_EMPTY_TEMPLATES code MSG_CODE_EXISTS MSG_CODE_EXISTS_FOR_LIBRARY MSG_NO_NOTICE_FOUND interface theme KohaTable columns_settings */ > >-var modal_loading = "<div id=\"loading\"><img src=\"" + interface + "/" + theme + "/img/spinner-small.gif\" alt=\"\" /> "+ MSG_DT_LOADING_RECORDS +"</div>"; >+var modal_loading = "<div id=\"loading\"><img src=\"" + interface + "/" + theme + "/img/spinner-small.gif\" alt=\"\" /> "+ __('Loading...') +"</div>"; > > var editing = 0; > if( add_form == 1 && code !== '' ){ >diff --git a/koha-tmpl/intranet-tmpl/prog/js/table_filters.js b/koha-tmpl/intranet-tmpl/prog/js/table_filters.js >index d7c4dc8988..85519b0c70 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/table_filters.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/table_filters.js >@@ -23,7 +23,7 @@ function activate_filters(id) { > } > > $('#' + id + '_activate_filters') >- .html('<i class="fa fa-filter"></i> ' + MSG_DEACTIVATE_FILTERS ) >+ .html('<i class="fa fa-filter"></i> ' + __('Deactivate filters') ) > .unbind('click') > .click(function() { > deactivate_filters(id); >@@ -41,7 +41,7 @@ function deactivate_filters(id) { > filters_row.hide(); > > $('#' + id + '_activate_filters') >- .html('<i class="fa fa-filter"></i> ' + MSG_ACTIVATE_FILTERS ) >+ .html('<i class="fa fa-filter"></i> ' + __('Activate filters') ) > .unbind('click') > .click(function() { > activate_filters(id); >-- >2.17.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 24662
:
98921
|
100147
|
100525