I have a site in 3 languages and a webform with a popup date picker. In the jquery.ui.datepicker.min.js file are the 3 datepicker.regional defaults (en-GB, es, pt-BR). I translate the site with the i18n module but don't know how make work correctly the date popup translation. It appears always in my default language pt-BR even when i am in the en-GB or es version of the site. When i delete the other datepicker.regional defaults from the .js file it appears correctly. Any help is apreciated. Thanks

Comments

rovi’s picture

Problem solved:
You can restore the default localizations with:
$.datepicker.setDefaults($.datepicker.regional['']);
And can then override an individual datepicker for a specific locale:
$(selector).datepicker($.datepicker.regional['fr']);

rovi’s picture

It was too early, not works, it is possible to have a form in 3 languages on separate pages and the popup display in english on the english form, portuguese popup on portuguese form and spanish popup on spanish form, i'm going crazy. Please help me

karens’s picture

Project: Date » Webform
Version: 7.x-2.0-alpha3 » 7.x-3.x-dev
Component: Date Popup » Code

Webform does not use the Date module fields, it handles its own dates.

jfd’s picture

I'm not sure I understand your question correctly. But it should be possible to localize the datepicker in webform.

You said, that you already have the correct translations in jquery.ui.datepicker.min.js. From what I can tell that is not the standard implementation as I only see the standard (english) localization in that file even though I have multiple languages installed, but this might be different depending on your module configuration.

You can however just set the corresponding translations in the document.ready method of the page you want the datepicker on. Include some Javascript and extend the jQuery.datepicker.regional[]-Array like for example this:

$.datepicker.regional['de'] = {
            closeText: 'schließen',
            prevText: '<zurück',
            nextText: 'Vor>',
            currentText: 'heute',
            monthNames: ['Januar','Februar','März','April','Mai','Juni',
            'Juli','August','September','Oktober','November','Dezember'],
            monthNamesShort: ['Jan','Feb','Mär','Apr','Mai','Jun',
            'Jul','Aug','Sep','Okt','Nov','Dez'],
            dayNames: ['Sonntag','Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag'],
            dayNamesShort: ['So','Mo','Di','Mi','Do','Fr','Sa'],
            dayNamesMin: ['So','Mo','Di','Mi','Do','Fr','Sa'],
            weekHeader: 'Wo',
            dateFormat: 'dd.mm.yy',
            firstDay: 1,
            isRTL: false,
            showMonthAfterYear: false,
            yearSuffix: ''
        };
$.datepicker.regional['fr'] = {...}
$.datepicker.regional['es'] = {...} 

Here is a list of all possible values: http://docs.jquery.com/UI/Datepicker/Localization

You can also include a set of predefined language-packs either remotely or locally: http://jquery-ui.googlecode.com/svn/trunk/ui/i18n/

You should then be able to set the default either globally by calling $.datepicker.setDefaults($.datepicker.regional['de']);
or for any individual datepicker by executing $('#your-datefield').datepicker('option', $.datepicker.regional['de']);

Note that I had trouble of getting this to work with the firstDay-Option, being stuck with the default set by webform, which is Sunday. Webform gets this value from a global option called date_first_day, which from my understanding should be set by the Date-Module, but in my case wasn't. You can remedy that by setting it explicitly somewhere in template.php (for example TEMPLATE_preprocess_html) like this variable_set('date_first_day', 1);

karens’s picture

The date_first_day variable is not set by Date module, it is set by core. And the variable will have no value if no one has ever visited the page to set it. None of the core date and time variables are set unless you visit the administration page and set them or use custom code to force values into them.

karens’s picture

Also see #507502: (needs documentation) Provide Locale support for jQuery UI. I was told in Date module NOT to add the translations and to leave it to core. However the core patch is still not in :(

quicksketch’s picture

Status: Active » Closed (fixed)

Marking this fixed as a support request. We're still pending on the core patch unfortunately, but there's nothing for us to do here.