Receive translated monthNames / dayNames as an array in Yii

Yii has many translations in the / i 18n / data /% lang% .php files. Here, for example, is a German translation

I want to use Fullcalendar in my Yii project. To translate this Calendar, I must provide an array of monthNames / dayNames for the current language. FullcalendarNames Documentation of the Month

What is the best way in Yii to generate an array like this:

['January', 'February', 'March', 'April', 'May', 'June', 'July',
 'August', 'September', 'October', 'November', 'December']
+5
source share
1 answer

You can generate this using json_encode(or Yii native CJSON::encode()) and the data provided by Yii:

json_encode(
    include('path/to/yii/framework/i18n/data/de_de.php')['monthNames']['wide']
);

( PHP 5.4 )

Yii, :

json_encode(
    Yii::app()->locale->getMonthNames()
)

. http://www.yiiframework.com/doc/api/1.1/CLocale#getMonthNames-detail

+6

All Articles