Sometimes it is necessary or desired to change certain text strings of the features like Search and Pagination, that are visible around a table. An example would be to change the word “Search:” to “Filter:” or similar. To achieve that, let’s first look at where these strings are stored. The “i18n/datatables/” folder of TablePress contains one DataTables language file for each available language. The file looks similar to this (this is the English file):
{
"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": "",
"lengthMenu": "Show _MENU_ entries",
"loadingRecords": "Loading...",
"processing": "Processing...",
"search": "Search:",
"zeroRecords": "No matching records found",
"paginate": {
"first": "First",
"previous": "Previous",
"next": "Next",
"last": "Last"
},
"aria": {
"sortAscending": ": activate to sort column ascending",
"sortDescending": ": activate to sort column descending"
},
"decimal": "",
"thousands": ","
}
Code language: JSON / JSON with Comments (json)
Changing strings directly in these files is a bad idea, as these changes would be reverted after each TablePress update (due to the way how plugin updates work). The Change DataTables strings Extension is a way around this problem.
Most strings in this file are self-explaining. Two of them are however not used for translations but for setting the data format of a number, e.g. for the sorting feature. Using the "decimal"
and "thousands"
parameters, the used number format can be changed. The default values in the example above will result in the traditional English format for a number, “100,000.00”. To use e.g. “100.000,00”, which is more common in Europe, the values have to be changed to "decimal": ","
and "thousands": "."
.
To use this Extension, just install and activate it like a regular WordPress plugin. Then copy the “lang-xy_XY.json” file of your language from the “tablepress/i18n/datatables/” folder to the “tablepress-change-datatables-strings” folder. (The “en_US” file is already in that folder, as an example.)
You can now change any string that is on the right side of a colon (:
) in that copied file. Make sure to not remove any of the quotation marks. Also, you can not use quotation marks in your changed strings! The words that are surrounded by an underscore (_
) are placeholders for the numbers or input fields that are automatically added by the DataTables script. You must not alter those (you can however put them in a new place within the string).
With the Extension activated, TablePress will now use the strings from the modified file.
If an Extension is useful for you, please check out the available TablePress Premium features and consider getting a Premium license plan, which bring even more features for you and your site visitors. Thank you!