Internationalisation plug-ins
Localisation of the presentation layer is important for any software package, and I aim to make this normally arduous task as easy as possible in DataTables. To this end, a number of contributors have kindly translated the language strings used is DataTables into various different languages. If you translate DataTables into any other languages, please get in touch or send a Github pull request.
How to use
In DataTables there are two initialisation methods by which you can include internationalisation options in DataTables:
- Loading the language file through an Ajax request (
language.url) - At initialisation time using the
languageproperty.
How you load the translation file will depend on how you are loading DataTables. If you are loading in the browser, use the .json files and set the language.url option. If you are using ESM or CommonJS, you would typically use the language option.
Browser
Loading DataTables' language information directly in the browser is done with the .json files - for example:
var table = new DataTable('#myTable', {
language: {
url: 'dataTables.german.json'
}
});
ES modules
When using ES modules (e.g. with Vite or similar bundler), you can use the datatables.net-plugins package (.mjs files) and include the translations from there:
import DataTable from 'datatables.net';
import languageDE from 'datatables.net-plugins/i18n/de-DE.mjs';
var table = new DataTable('#myTable', {
language: languageDE
});