Translation of the datepicker

Questions and bug reports for current release of CKForms

Translation of the datepicker

Postby jacobo221 » Mon Sep 28, 2009 5:35 am

I love CK Forms but the datepicker not being localizable was a complete showstopper for my site. Here is the patch i've done to make it automatically switch between the different datepicker languages depending on the user's Joomla language:

(This patch applies to CK Forms 1.3.2 build 3)

We simply have to modify the CK Forms template. So, edit components/com_ckforms/views/ckforms/tmpl/default.php. After line 190 add this line:

Code: Select all
<script type="text/javascript" src="<?php echo JURI::root(true).'/components/com_ckforms/js/ui/ui.datepicker-'.$_GET['lang'].'.js'; ?>"></script>


Then in line 195 replace
Code: Select all
"en"
with
Code: Select all
"<?php echo $_GET['lang']; ?>"
.

So the resulting code (and some of its surrounding code) should look like this:

Code: Select all
        <input type="text" name="<?php echo $field->name; ?>" id="<?php echo $field->name; ?>" value="<?php echo $field->t_initvalueT; ?>" class="inputbox ckrequired ckCSSinputnormal <?php if ($field->custominfo != "") {echo "ckCSSTip";} else {echo "ckCSSnoTip";} ?> <?php echo $field->fieldCSSclass; ?>" maxlength="<?php echo $field->t_maxchar; ?>" <?php if ($field->readonly == "1") {echo ' readonly="true"';} ?> />
<?php   
         break;
         case 'date':
?>
<script type="text/javascript" src="<?php echo JURI::root(true).'/components/com_ckforms/js/ui/ui.datepicker-'.$_GET['lang'].'.js'; ?>"></script>
<script type="text/javascript">
<!--
    JNC_jQuery(function() {
        JNC_jQuery("#<?php echo $field->name; ?>").datepicker(JNC_jQuery.extend({}, JNC_jQuery.datepicker.regional["<?php echo $_GET['lang']; ?>"], {
            dateFormat: "dd/mm/yy",
            showOn: "both",
            buttonImage: "<?php echo JURI::root(true).'/components/com_ckforms/' ?>img/calendar.gif",
            buttonImageOnly: true,
            yearRange: '-100:+5',
            changeYear: true,
            currentText: 'Now'
        }));
    });
// -->
</script>


Now you must create/adapt the corresponding translations in components/com_ckforms/js/ui/ui.datepicker-XX.js (where XX stands for the language code, i.e. "en" for english, "es" for spanish, "ca" for catalan, "fr" for french, ...) for every language that your Joomle site supports.

Comment: You can change the first day of the week to monday instead of sunday on each datepicker translation by setting firstDay:1 (instead of the default firstDay:0).

NOTE: If the corresponding ui.datepicker-XX.js does not exist CK Forms will default to the builtin english.
jacobo221
 
Posts: 3
Joined: Mon Sep 28, 2009 5:14 am
Top

Return to CKForms 1.3.x Support forum

Who is online

Users browsing this forum: Alexa [Bot] and 0 guests