Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Localize missing strings on the Table page #111

Open
joaopalmeiro opened this issue Aug 22, 2024 · 0 comments
Open

Localize missing strings on the Table page #111

joaopalmeiro opened this issue Aug 22, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@joaopalmeiro
Copy link
Contributor

joaopalmeiro commented Aug 22, 2024

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

@joaopalmeiro joaopalmeiro added the enhancement New feature or request label Aug 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant