views:

115

answers:

2

I've got a multi-lingual Drupal 6 installation. The multi-language is provided by the i18n module.

I'm displaying some date pickers using jquery ui's datepicker. I'd like to localize those datepickers too (so when the page being shown is English, they show 'mon tue wed ...' but when the page is in Spanish they show 'lun mar mi ...').

My problem is: I don't know how to send the currently selected locale to javascript.

The closest thing I could find was the javascript Drupal.locale object. However that object doesn't seem to have a 'locale name'.

+2  A: 

http://drupal.org/node/775876 looks like what you want. It seems the language is not exposed to javascript by default, so you'll have to do that in php. If you're using the CCK Date field you can just apply the patch I linked to.

Fabian
This helped me out on finding the correct answer. Thanks!
egarcia
A: 

I ended up implementing my own solution.

The locale can be obtained (in php) by calling i18n_get_lang.

Since I had jquery-ui on my theme, it made sense to just include the right .js file depending on the locale. So I added this at the end of my_theme_preprocess_page, inside the theme's template.php file:

/* File template.php */

function my_theme_preprocess_page() {
  ...


  /* include locale-specific ui file */
  drupal_add_js (path_to_theme() . '/js/jquery-ui/ui/i18n/ui.datepicker-'.(i18n_get_lang()).'.js');
  $vars['scripts']=drupal_get_js().$vars['scripts'];

end

Thanks a lot!

egarcia