Download & Extend

Change Jquery UI datepicker language

Project:Better Exposed Filters
Version:7.x-3.0-beta1
Component:Miscellaneous
Category:feature request
Priority:normal
Assigned:mikeker
Status:active

Issue Summary

Hello!

I haven't found any way to change the datepicker popup language.
I've tried to modify my theme's js but it doesn't work (with this) :

jQuery.datepicker.regional['fr'] = {
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: ''};

... I think it's because BEF includes js script at the end of document just before

There is a trick to do this ?

Thanks a lot...

Comments

#1

Re ...

I've found a solution (not very clean ... :)
In the file "better_exposed_filters_exposed_form_plugin.inc" lines 361 to 374, I've changed this :

          // Add Datepicker JS and CSS
          drupal_add_js('misc/ui/jquery.ui.datepicker.min.js');
          drupal_add_css('misc/ui/jquery.ui.datepicker.css');

          if (isset($form[$field_id]['value']['#type']) && 'date_text' == $form[$field_id]['value']['#type']) {
            // Date module does it's own processing of the date field so we
            // can't really control the ID of the text field element.
            $matches = array();
            preg_match('/\bid="(.*?)"/', $form[$field_id]['value']['#prefix'], $matches);
            $id = $matches[1];
            drupal_add_js("jQuery(document).ready(function () { jQuery('#$id input').datepicker({dateFormat: 'yy-mm-dd'}); });",
              array('type' => 'inline', 'scope' => 'footer')
            );
          }

to this

          // Add Datepicker JS and CSS
          drupal_add_js('sites/all/modules/jquery_update/replace/ui/ui/minified/jquery.ui.datepicker.min.js'); //Jquery Update Ui datepicker
  drupal_add_js('sites/all/modules/jquery_update/replace/ui/ui/i18n/jquery.ui.datepicker-fr.js'); //MODIFYING Language
          drupal_add_css('sites/all/themes/site1/css/jquery.ui/jquery-ui-1.8.16.custom.css'); //MY OWN CSS

          if (isset($form[$field_id]['value']['#type']) && 'date_text' == $form[$field_id]['value']['#type']) {
            // Date module does it's own processing of the date field so we
            // can't really control the ID of the text field element.
            $matches = array();
            preg_match('/\bid="(.*?)"/', $form[$field_id]['value']['#prefix'], $matches);
            $id = $matches[1];
            drupal_add_js("jQuery(document).ready(function () { jQuery('#$id input').datepicker();", //Date Format Deleted
              array('type' => 'inline', 'scope' => 'footer')
            );
          }

That's all.
It would be nice if this could be modified in module admin setting for example, picking js file if user wants to change them, and specify date format as variable ...

It's a suggestion like a other.

#2

Assigned to:Anonymous» mikeker

I looked more closely at this issue and I should be using the hook_library and drupal_add_library routines instead of the mess of drupal_add_js I'm currently using.

Will work on fixing that soon....