Viewing 9 reply threads
  • Author
    Posts
    • #5436
      vayu
      Member

      Hi, how do I change the language of the datepicker. I tried to do it via the options and via javascript, but none seem to work.

    • #5450
      Steve
      Keymaster

      @vayu– Piklist uses the jQuery UI datepicker which is built into WordPress.

      You need to pass your translated variables through the options parameter. Here’s an example in French:

        piklist('field', array(
          'type' => 'datepicker'
          ,'field' => 'my-date-field'
          ,'label' => 'Date'
          ,'options' => array(
            'closeText'=>'Fermer',
            'prevText'=>'Précédent',
            'nextText'=>'Suivant',
            'currentText'=>'Aujourd\'hui',
            'monthNames'=>['Janvier','Février','Mars','Avril','Mai','Juin','Juillet','Août','Septembre','Octobre','Novembre','Décembre'],
            'monthNamesShort'=>['Janv.','Févr.','Mars','Avril','Mai','Juin','Juil.','Août','Sept.','Oct.','Nov.','Déc.'],
            'dayNames'=>['Dimanche','Lundi','Mardi','Mercredi','Jeudi','Vendredi','Samedi'],
            'dayNamesShort'=>['Dim.','Lun.','Mar.','Mer.','Jeu.','Ven.','Sam.'],
            'dayNamesMin'=>['D','L','M','M','J','V','S'],
            'weekHeader'=>'Sem.',
            'dateFormat'=>'dd/mm/yy',
            'firstDay'=>1,
            'isRTL'=>false,
            'showMonthAfterYear'=>false,
            'yearSuffix'=>''
          )
        ));
      
      

      You may also be able to load one of these translation files, though I haven’t tried it.

    • #5453
      vayu
      Member

      This is great, thanks! Do you have any advice on how to find information about all such extra options/attributes for the different fields, because I could not find this in the docs?

    • #5454
      Steve
      Keymaster

      @vayu– The jQuery docs seem to be lacking. Honestly, I Googled it and found the answer. 😉

    • #5456
      vayu
      Member

      Thanks, I did google it as well and tried several things, but actually I meant for Piklist options, not specifically for datepicker. There is no information about being able to use these options in the Piklist docs.

    • #5458
      Steve
      Keymaster

      @vayu– The Piklist options for the datepicker are the same for every Piklist field. We try not to duplicate information from other codexes, and parameters that go in the options array are really being created by JQuery UI, not Piklist.

      Does that make sense?

    • #5459
      vayu
      Member

      Okay thanks. Maybe I just don’t really understand the options parameter. Is this only for jQuery options?

    • #5460
      Steve
      Keymaster

      In most cases, with the exception of validation and sanitization, the options array is not determined by Piklist, but by the underlying library. jQuery UI fields… the WordPress media uploader… etc.

      But we do this with our documentation everywhere (and probably should explain it better). For instance, when registering a Post Type using Piklist, we only document the unique Piklist parameters, but you can also use every WordPress parameter in register_post_type as well.

    • #5461
      vayu
      Member

      Thank you for explaining this for me. 🙂

    • #5462
      Steve
      Keymaster

      Thank you for letting us know we need to explain it better 😉

Viewing 9 reply threads
  • The topic ‘datepicker regional’ is closed to new replies.