vincjo / datatables

A toolkit for creating datatable components with Svelte
https://vincjo.fr/datatables
MIT License
372 stars 15 forks source link

[SUGGESTION] Add support for different text in Datatable #10

Closed 0x1AE7F closed 1 year ago

0x1AE7F commented 1 year ago

Hey! This project is great make good data tables fast and im using it in a few of my projects which are in german but every text of the data table is english.. Is there some way to change that without really changing the actual source code ( because that would mean that people would have to make the same changes when downloading my project.. ) or is there already some functionality I did not know of?

vincjo commented 1 year ago

Hello, glad you found this lib useful.

There is actually a way to translate the components, by passing an i18n object to the DataHandler params, as shown below:

    const handler = new DataHandler(myData, { 
        rowsPerPage: 10, 
        i18n: {
            search: 'Search...',
            show: 'Show', 
            entries: 'lines',
            filter: 'Filter',
            rowCount: 'Showing {start} to {end} of {total} entries',
            noRows: 'No entries to found',
            previous: 'Previous', 
            next: 'Next'
        }
    })

these are the default values ​​that you can adapt in German

0x1AE7F commented 1 year ago

Thank you very much!