Hello,

I'm using cakePHP version 1.1.19.6502.

In order to localized the months values in french in the HtmlHelper, I
copy the html helper in the app\views\helpers folder and I modified
this function:

{{{
    /**
     * Returns a SELECT element for months.
     *
     * @param string $tagName Prefix name for the SELECT element
     * @param string $selected Option which is selected.
     * @param array $optionAttr Attribute array for the option
elements.
     * @param boolean $showEmpty Show/hide the empty select option
     * @param string $lang Select the months language.
     * @return mixed
     * @access public
     */
        function monthOptionTag( $tagName, $value = null, $selected = null,
$selectAttr = null, $optionAttr = null, $showEmpty = true, $lang =
null ) {
                if(empty($selected) && ($this->tagValue($tagName))) {
                        $selected = date('m', 
strtotime($this->tagValue($tagName)));
                }
                $monthValue = empty($selected) ? ($showEmpty ? NULL : 
date('m')) :
$selected ;

        switch( $lang )
        {
                case 'en' :
                $months = array(
                        '01' => 'January',
                        '02' => 'February',
                        '03' => 'March',
                        '04' => 'April',
                        '05' => 'May',
                        '06' => 'June',
                        '07' => 'July',
                        '08' => 'August',
                        '09' => 'September',
                        '10' => 'October',
                        '11' => 'November',
                        '12' => 'December'
                    ) ;
                break ;

            case 'fr' :
                $months = array(
                        '01' => 'Janvier',
                        '02' => 'Fevrier',
                        '03' => 'Mars',
                        '04' => 'Avril',
                        '05' => 'Mai',
                        '06' => 'Juin',
                        '07' => 'Jullet',
                        '08' => 'AƓut',
                        '09' => 'Septembre',
                        '10' => 'Octobre',
                        '11' => 'Novembre',
                        '12' => 'Decembre'
                    ) ;
                break ;

            default :
                $months = array(
                        '01' => 'January',
                        '02' => 'February',
                        '03' => 'March',
                        '04' => 'April',
                        '05' => 'May',
                        '06' => 'June',
                        '07' => 'July',
                        '08' => 'August',
                        '09' => 'September',
                        '10' => 'October',
                        '11' => 'November',
                        '12' => 'December'
                    ) ;
                break ;
        }

                return $this->selectTag($tagName . "_month", $months, 
$monthValue,
$selectAttr, $optionAttr, $showEmpty);
        }

}}}

Is that correct and useful ?

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to