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

Elements translation #178

Closed
bugriy opened this issue Apr 17, 2023 · 4 comments · Fixed by #235
Closed

Elements translation #178

bugriy opened this issue Apr 17, 2023 · 4 comments · Fixed by #235

Comments

@bugriy
Copy link

bugriy commented Apr 17, 2023

Is it possible to translate "Show", "entries", "Next" to other languages?

@mwouts
Copy link
Owner

mwouts commented Apr 22, 2023

Hey @bugriy , great question, thanks for asking. The datatables.net library that we use in itables does support internationalisation, cf. https://datatables.net/plug-ins/i18n/ and https://datatables.net/reference/option/language

Maybe the second one should be easier to use. Can you try passing a language dict to the show method that would be inspired from https://datatables.net/reference/option/language ?

@mwouts
Copy link
Owner

mwouts commented Apr 22, 2023

This seems to work (please translate it according to your needs):

import itables.options as opt

opt.language = {
    "decimal":        "",
    "emptyTable":     "No data available in table",
    "info":           "Showing _START_ to _END_ of _TOTAL_ entries",
    "infoEmpty":      "Showing 0 to 0 of 0 entries",
    "infoFiltered":   "(filtered from _MAX_ total entries)",
    "infoPostFix":    "",
    "thousands":      ",",
    "lengthMenu":     "Show _MENU_ entries",
    "loadingRecords": "Loading...",
    "processing":     "",
    "search":         "Search:",
    "zeroRecords":    "No matching records found",
    "paginate": {
        "first":      "First",
        "last":       "Last",
        "next":       "Next",
        "previous":   "Previous"
    },
    "aria": {
        "sortAscending":  ": activate to sort column ascending",
        "sortDescending": ": activate to sort column descending"
    }
}

@s1lvester
Copy link

s1lvester commented Feb 5, 2024

Datatables already has a huge list of i18n Plugins (see: https://datatables.net/plug-ins/i18n/) and as far as I understand @mwouts put Plugin-Support on the Roadmap for itables v2.

Up until then, one can just copy the Plug-In Code (in my case German: https://datatables.net/plug-ins/i18n/German.html#Plug-in-code) from the plugin website and pass the whole json to itables.options.language as shown above, thereby saving some effort on translating.

@mwouts mwouts mentioned this issue Mar 11, 2024
7 tasks
@mwouts
Copy link
Owner

mwouts commented Mar 16, 2024

Actually internationalization was the easiest of the plugins! I've just documented this here. I have tested this with itables==2.0 but it might also work with the previous versions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants