Expose bootstrap table strings to translation layer

This commit is contained in:
Oliver Walters 2021-01-29 12:04:36 +11:00
parent 8c7621d4bc
commit c1a54ddffd
3 changed files with 46 additions and 2 deletions

View File

@ -105,6 +105,7 @@ dynamic_javascript_urls = [
url(r'^label.js', DynamicJsView.as_view(template_name='js/label.js'), name='label.js'), 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'^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'^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'), url(r'^table_filters.js', DynamicJsView.as_view(template_name='js/table_filters.js'), name='table_filters.js'),
] ]

View File

@ -111,7 +111,6 @@ InvenTree
<script type='text/javascript' src="{% static 'script/inventree/inventree.js' %}"></script> <script type='text/javascript' src="{% static 'script/inventree/inventree.js' %}"></script>
<script type='text/javascript' src="{% static 'script/inventree/api.js' %}"></script> <script type='text/javascript' src="{% static 'script/inventree/api.js' %}"></script>
<script type='text/javascript' src="{% static 'script/inventree/filters.js' %}"></script> <script type='text/javascript' src="{% static 'script/inventree/filters.js' %}"></script>
<script type='text/javascript' src="{% static 'script/inventree/tables.js' %}"></script>
<script type='text/javascript' src="{% static 'script/inventree/notification.js' %}"></script> <script type='text/javascript' src="{% static 'script/inventree/notification.js' %}"></script>
<script type='text/javascript' src="{% static 'script/inventree/sidenav.js' %}"></script> <script type='text/javascript' src="{% static 'script/inventree/sidenav.js' %}"></script>
@ -126,6 +125,7 @@ InvenTree
<script type='text/javascript' src="{% url 'build.js' %}"></script> <script type='text/javascript' src="{% url 'build.js' %}"></script>
<script type='text/javascript' src="{% url 'order.js' %}"></script> <script type='text/javascript' src="{% url 'order.js' %}"></script>
<script type='text/javascript' src="{% url 'calendar.js' %}"></script> <script type='text/javascript' src="{% url 'calendar.js' %}"></script>
<script type='text/javascript' src="{% url 'tables.js' %}"></script>
<script type='text/javascript' src="{% url 'table_filters.js' %}"></script> <script type='text/javascript' src="{% url 'table_filters.js' %}"></script>
<script type='text/javascript' src="{% static 'fontawesome/js/solid.js' %}"></script> <script type='text/javascript' src="{% static 'fontawesome/js/solid.js' %}"></script>

View File

@ -1,3 +1,5 @@
{% load i18n %}
function editButton(url, text='Edit') { function editButton(url, text='Edit') {
return "<button class='btn btn-success edit-button btn-sm' type='button' url='" + url + "'>" + text + "</button>"; return "<button class='btn btn-success edit-button btn-sm' type='button' url='" + url + "'>" + text + "</button>";
} }
@ -263,4 +265,45 @@ function customGroupSorter(sortName, sortOrder, sortData) {
return 0; return 0;
} }
}); });
} }
// 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);