From c1a54ddffddb12349a7301d1fe775d4596626afb Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Fri, 29 Jan 2021 12:04:36 +1100 Subject: [PATCH] Expose bootstrap table strings to translation layer --- InvenTree/InvenTree/urls.py | 1 + InvenTree/templates/base.html | 2 +- .../inventree => templates/js}/tables.js | 45 ++++++++++++++++++- 3 files changed, 46 insertions(+), 2 deletions(-) rename InvenTree/{InvenTree/static/script/inventree => templates/js}/tables.js (83%) diff --git a/InvenTree/InvenTree/urls.py b/InvenTree/InvenTree/urls.py index 9ad7780122..2c56b8eeb1 100644 --- a/InvenTree/InvenTree/urls.py +++ b/InvenTree/InvenTree/urls.py @@ -105,6 +105,7 @@ dynamic_javascript_urls = [ url(r'^label.js', DynamicJsView.as_view(template_name='js/label.js'), name='label.js'), url(r'^report.js', DynamicJsView.as_view(template_name='js/report.js'), name='report.js'), url(r'^stock.js', DynamicJsView.as_view(template_name='js/stock.js'), name='stock.js'), + url(r'^tables.js', DynamicJsView.as_view(template_name='js/tables.js'), name='tables.js'), url(r'^table_filters.js', DynamicJsView.as_view(template_name='js/table_filters.js'), name='table_filters.js'), ] diff --git a/InvenTree/templates/base.html b/InvenTree/templates/base.html index f7ee1b2f19..1e6de2fb21 100644 --- a/InvenTree/templates/base.html +++ b/InvenTree/templates/base.html @@ -111,7 +111,6 @@ InvenTree - @@ -126,6 +125,7 @@ InvenTree + diff --git a/InvenTree/InvenTree/static/script/inventree/tables.js b/InvenTree/templates/js/tables.js similarity index 83% rename from InvenTree/InvenTree/static/script/inventree/tables.js rename to InvenTree/templates/js/tables.js index 21f9160758..9bb10552bf 100644 --- a/InvenTree/InvenTree/static/script/inventree/tables.js +++ b/InvenTree/templates/js/tables.js @@ -1,3 +1,5 @@ +{% load i18n %} + function editButton(url, text='Edit') { return ""; } @@ -263,4 +265,45 @@ function customGroupSorter(sortName, sortOrder, sortData) { return 0; } }); -} \ No newline at end of file +} + +// Expose default bootstrap table string literals to translation layer +(function ($) { + 'use strict'; + + $.fn.bootstrapTable.locales['en-US-custom'] = { + formatLoadingMessage: function () { + return '{% trans "Loading data" %}'; + }, + formatRecordsPerPage: function (pageNumber) { + return `${pageNumber} {% trans "rows per page" %}`; + }, + formatShowingRows: function (pageFrom, pageTo, totalRows) { + return `{% trans "Showing" %} ${pageFrom} {% trans "to" %} ${pageTo} {% trans "of" %} ${totalRows} {% trans "rows" %}`; + }, + formatSearch: function () { + return '{% trans "Search" %}'; + }, + formatNoMatches: function () { + return '{% trans "No matching results" %}'; + }, + formatPaginationSwitch: function () { + return '{% trans "Hide/Show pagination" %}'; + }, + formatRefresh: function () { + return '{% trans "Refresh" %}'; + }, + formatToggle: function () { + return '{% trans "Toggle" %}'; + }, + formatColumns: function () { + return '{% trans "Columns" %}'; + }, + formatAllRows: function () { + return '{% trans "All" %}'; + } + }; + + $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales['en-US-custom']); + +})(jQuery); \ No newline at end of file