jqueryjquery-uicontact-form-7

Change Language Of Date Picker in Contact Form 7


I have a site that is translated into two languages; English and Turkish. I want the datepicker on this turkish page to display the datepicker UI in the Turkish Language and not the default English Language. Clearly simply using two different forms does not solve the problem. I have tried solutions from this, this and even the demo page but I still get errors. So either I am applying them wrongly or am missing something. I even included the language source code from the jQuery CDN, downloaded a copy to the server but still the results are not positive. Below is the current code, it gives no errors as it is now but it still does not work.

In The Contact Form:

    <tr><td>Tarih</td><td>:</td><td>[date* tarih id:tarih]</td></tr>

The CSS head tag for the page.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script data-require="jqueryui@*" data-semver="1.10.0" src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.9.2/i18n/jquery.ui.datepicker-tr.min.js"></script>
<link data-require="jqueryui@*" data-semver="1.10.0" rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.10.0/css/smoothness/jquery-ui-1.10.0.custom.min.css" />
<script data-require="jqueryui@*" data-semver="1.10.0" src="//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.10.0/jquery-ui.js"></script>

The Javascript

<script type="text/javascript">
    $(document).ready(function() {
      var options = $.extend(
        {},                                  
        $.datepicker.regional["tr"], 
        { dateFormat: "dd.mm.yy" } 
        );
        $.datepicker.setDefaults(options);
    });
  </script>

Solution

  • Modern browsers render datepicker directly. Change your browser language to render the data picker in your local language.

    There is a way to set the locale of a datepicker element, see this answer.