Skip to content

Localize missing strings on the Table page #111

@joaopalmeiro

Description

@joaopalmeiro

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:

Screenshot 2024-08-22 at 12 27 25 Screenshot 2024-08-22 at 12 27 43

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:

'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'
    ]

'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'
    ]

@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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions