How to translate the DataTables script
A View on the DataTables Table layout shows its controls in the language of your site: the search box, the Show entries menu, the count of entries, the page links and the export buttons. DataTables needs a translation for that language, and without one the controls stay in English. To change the site’s language, go to Settings, then General, and choose a Site Language.
DataTables is built into GravityView Pro. To turn it on or off, go to Plugins and click Features in the GravityView Pro row.
Showing the controls in another language #
To show the DataTables controls in a language other than the site’s, add this code to your site. This example uses German:
add_filter( 'gravityview/datatables/config/locale', 'gk_dt_locale', 10, 2 );
/**
* Shows the DataTables controls in German, whatever the site language is.
*
* @param string $locale The site's locale, such as en_US.
* @param array $translations The locales that have a DataTables translation.
*
* @return string The locale whose translation DataTables uses.
*/
function gk_dt_locale( $locale, $translations ) {
return 'de_DE';
}Note: Adding custom PHP code snippets to your website shows where to add this code.
Replace de_DE with the WordPress locale code of the language you want, such as fr_FR for French, es_ES for Spanish or pt_BR for Brazilian Portuguese.
The code changes the DataTables controls only. The export buttons and the All choice in the Show entries menu keep the site’s language.

Changing one piece of text #
To change a single string, such as the label of the search box, filter the strings themselves. This code changes the search label to Find a seller:
add_filter( 'gravityview/datatables/config/language', 'gk_dt_search_label', 10, 3 );
/**
* Changes the label of the DataTables search box.
*
* @param array $language The DataTables strings, translated for $locale.
* @param array $translations The locales that have a DataTables translation.
* @param string $locale The locale of the translation.
*
* @return array The DataTables strings.
*/
function gk_dt_search_label( $language, $translations, $locale ) {
$language['search'] = 'Find a seller:';
return $language;
}Note: Adding custom PHP code snippets to your website shows where to add this code.
The key search is the label of the search box.
For the parameters of the first filter, see gravityview/datatables/config/locale on gravitykit.dev.