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!

    1. 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.
    2. 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’s it, your Date Picker in Gravity Forms will now show the names of the weekdays and months in French!

Questions? Let us know in the comments below.

Share This Story, Help Your Friends And Family!

Get the latest news to help you succeed online

Name(Required)
This field is for validation purposes and should be left unchanged.

Check our Privacy Policy.

2 Comments

  1. Vik 16 September 2022 at 11:33 pm - Reply

    that does not work at all

    • Aurelien 27 September 2022 at 4:22 am - Reply

      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!

Leave A Comment