Gravity Forms is one of the best plugins for creating forms in WordPress.
But when you need to translate something as unique as the way the dates are shown on a Date Picker you’ve added to a contact/booking form for your users’ convenience, it may become a bit challenging.
It’s actually easy!
- Copy the code from this file and save it as “datepicker-fr.js” to the /js/ directory of your active theme using an app like TextWrangler for example. If you don’t have a js directory or if you’re using a Child Theme, simply create an empty folder through FTP on wp content > themes > name of your theme, name it “js” and upload the newly created file.
- Copy the following code and place it into your theme functions.php file using an FTP app or in the WordPress backend under “Appearance > Editor”:
add_action( 'gform_enqueue_scripts', 'add_datepicker_regional', 11 );
function add_datepicker_regional() {
if ( wp_script_is( 'gform_datepicker_init' ) ) {
wp_enqueue_script( 'datepicker-regional', get_stylesheet_directory_uri() . '/js/datepicker-your-lang.js', array( 'gform_datepicker_init' ), false, true );
remove_action( 'wp_enqueue_scripts', 'wp_localize_jquery_ui_datepicker', 1000 );
}
}
You just have to replace “datepicker-your-lang.js” by “datepicker-fr.js”.
We would recommend to add a comment just above your code to state what it’s for for future reference.
that does not work at all
Thanks Vik for your comment.
It may be due to the fact that this solution worked on Gravity Forms version 2.4 and prior.
Since version 2.5, Gravity Forms has revamped everything and there’s another way to translate the Date Picker.
Here’s an article that may help you: https://docs.gravityforms.com/translating-the-datepicker/
Thanks, we hope it helps!