-
-
Notifications
You must be signed in to change notification settings - Fork 34
Description
Hi! 👋
Is your feature request related to a problem? Please describe.
The Table page currently has two non-localized strings, written in English instead of Portuguese when Portuguese is the selected language:


Describe the solution you'd like
These two strings, Search:
and Showing 1 to 14 of 14 entries
, are localized and adapted to the domain. As a suggestion, leveraging DataTables and Laravel features, I would change the following files as follows:
fogospt/fogospt/resources/lang/pt/pages.php
Lines 103 to 105 in c460e44
'list' => [ | |
'no-data' => 'Sem registo de incêndios' | |
] |
'list' => [
'no-data' => 'Sem registo de incêndios',
'data' => 'A mostrar :number incêndio|A mostrar :number incêndios',
'data-filtered' => 'A mostrar :number incêndio (filtrado de um total de :total)|A mostrar :number incêndios (filtrado de um total de :total)',
'search' => 'Pesquisar'
]
fogospt/fogospt/resources/lang/en/pages.php
Lines 90 to 92 in c460e44
'list' => [ | |
'no-data' => 'Sem registo de incêndios' | |
] |
'list' => [
'no-data' => 'No fire incidents',
'data' => 'Showing :number fire incident|Showing :number fire incidents',
'data-filtered' => 'Showing :number fire incident (filtered from a total of :total)|Showing :number fire incidents (filtered from a total of :total)',
'search' => 'Search'
]
fogospt/fogospt/resources/views/table.blade.php
Lines 58 to 73 in c460e44
@push('scripts') | |
<script src="//cdn.datatables.net/1.10.21/js/jquery.dataTables.min.js"></script> | |
<script> | |
$(document).ready( function () { | |
$('#fires').DataTable({ | |
paging: false, | |
stateSave: true, | |
order: [[ 0, 'desc' ]] | |
}); | |
setTimeout(function() { | |
location.reload(); | |
}, 180000); | |
} ); | |
</script> | |
@endpush |
@push('scripts')
<script src="//cdn.datatables.net/1.10.21/js/jquery.dataTables.min.js"></script>
<script>
$(document).ready( function () {
$('#fires').DataTable({
paging: false,
stateSave: true,
order: [[ 0, 'desc' ]],
language: {
"search": "{{ trans('pages.list.search') }}"
},
infoCallback: function (settings, start, end, max, total, pre) {
// If the table is filtered:
if (max !== total) {
return total === 1
? "{{ trans_choice('pages.list.data-filtered', 1, ['number' => 1]) }}".replace(
":total",
max,
)
: "{{ trans_choice('pages.list.data-filtered', 2) }}"
.replace(":number", total)
.replace(":total", max);
}
return total === 1
? "{{ trans_choice('pages.list.data', 1, ['number' => 1]) }}"
: "{{ trans_choice('pages.list.data', 2) }}".replace(
":number",
total,
);
},
});
setTimeout(function() {
location.reload();
}, 180000);
} );
</script>
@endpush
This way, the final result will look like this:
small.mov
I suggest simplifying the string for table entries, given that the table is not paged. Also, given that I have no experience with Laravel, I'm not sure if there is a simpler approach to combining it with DataTables.
Let me know what you think and if I can open a PR. Thanks!
Additional context
- Operating System and version: macOS Sonoma 14.5
- Browser and version: Chrome 127.0.6533.89
References
- https://datatables.net/reference/option/language
- https://datatables.net/reference/api/i18n()
- https://datatables.net/reference/option/infoCallback
- https://datatables.net/forums/discussion/35330/language-info-how-to-change-message-when-theres-only-one-entry-feature-request
- https://laravel.com/docs/7.x/localization
- https://laravel.com/docs/7.x/helpers#method-trans