Skip to content

Commit

Permalink
added internalizations
Browse files Browse the repository at this point in the history
  • Loading branch information
marekpetras committed Aug 18, 2016
1 parent e4e2ca6 commit 55357e4
Show file tree
Hide file tree
Showing 10 changed files with 305 additions and 19 deletions.
20 changes: 19 additions & 1 deletion CalendarView.php
Expand Up @@ -210,9 +210,27 @@ public function init()
$this->endYear = date('Y') + 1;
}

$this->registerTranslations();

parent::init();
}

/**
* Register translations with Yii
* @return void
*/
public function registerTranslations()
{
Yii::$app->i18n->translations['calendar'] = [
'class' => 'yii\i18n\PhpMessageSource',
'sourceLanguage' => 'en-US',
'basePath' => '@vendor/marekpetras/yii2-calendarview-widget/messages',
'fileMap' => [
'calendar' => 'calendar.php',
],
];
}

/**
* Renders the calendar
* @return string the rendering result
Expand Down Expand Up @@ -327,7 +345,7 @@ protected function renderMonth($month = null, $year = null)
}

return $this->view->render($this->views['month'],[
'title' => $first->format('F Y'),
'title' => Yii::t('calendar',$first->format('F')).$first->format(' Y'),
'content' => $html,
'monthRendered' => $first->format('Y')*12+$first->format('m'),
]);
Expand Down
2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -9,6 +9,8 @@ About
Ever needed to display table records as a calendar display using just a data provider and a date field?
Using Bootstrap 3 and jQuery to create a responsive calendar widget which displays any number of events.

Now with internalizations into 7 languages (slovak, czech, german, english, spanish, russian, and polish), for additional translations send pull requests please.

![CalendarView Widget](https://dl.dropboxusercontent.com/u/44806680/yii2-calendarview-widget.png "CalendarView Widget")

Installation
Expand Down
38 changes: 38 additions & 0 deletions messages/cs/calendar.php
@@ -0,0 +1,38 @@
<?php
/**
* Message translations.
*
* NOTE: this file must be saved in UTF-8 encoding.
*/
return [
'Previous' => 'Předchozí',
'Next' => 'Další',
'Week' => 'Týden',
'Monday' => 'Pondělí',
'Tuesday' => 'Úterý',
'Wednesday' => 'Středa',
'Thursday' => 'Čtvrtek',
'Friday' => 'Pátek',
'Saturday' => 'Sobota',
'Sunday' => 'Neděle',
'W' => 'T',
'Mo' => 'Po',
'Tu' => 'Út',
'We' => 'St',
'Th' => 'Čt',
'Fr' => 'Pá',
'Sa' => 'So',
'Su' => 'Ne',
'January' => 'Leden',
'February' => 'Únor',
'March' => 'Březen',
'April' => 'Duben',
'May' => 'Květen',
'June' => 'Červen',
'July' => 'Červenec',
'August' => 'Srpen',
'September' => 'Září',
'October' => 'Říjen',
'November' => 'Listopad',
'December' => 'Prosinec',
];
38 changes: 38 additions & 0 deletions messages/de/calendar.php
@@ -0,0 +1,38 @@
<?php
/**
* Message translations.
*
* NOTE: this file must be saved in UTF-8 encoding.
*/
return [
'Previous' => 'Früher',
'Next' => 'Nächster',
'Week' => 'Woche',
'Monday' => 'Montag',
'Tuesday' => 'Dienstag',
'Wednesday' => 'Mittwoch',
'Thursday' => 'Donnerstag',
'Friday' => 'Freitag',
'Saturday' => 'Samstag',
'Sunday' => 'Sonntag',
'W' => 'W',
'Mo' => 'Mo',
'Tu' => 'Di',
'We' => 'Mi',
'Th' => 'Do',
'Fr' => 'Fr',
'Sa' => 'Sa',
'Su' => 'So',
'January' => 'Januar',
'February' => 'Februar',
'March' => 'März',
'April' => 'April',
'May' => 'Mai',
'June' => 'Juni',
'July' => 'Juli',
'August' => 'August',
'September' => 'September',
'October' => 'Oktober',
'November' => 'November',
'December' => 'Dezember',
];
38 changes: 38 additions & 0 deletions messages/es/calendar.php
@@ -0,0 +1,38 @@
<?php
/**
* Message translations.
*
* NOTE: this file must be saved in UTF-8 encoding.
*/
return [
'Previous' => 'Anterior',
'Next' => 'Siguiente',
'Week' => 'Semana',
'Monday' => 'Lunes',
'Tuesday' => 'Martes',
'Wednesday' => 'Miércoles',
'Thursday' => 'Jueves',
'Friday' => 'Viernes',
'Saturday' => 'Sábado',
'Sunday' => 'Domingo',
'W' => 'S',
'Mo' => 'Lu',
'Tu' => 'Ma',
'We' => 'Mi',
'Th' => 'Ju',
'Fr' => 'Vi',
'Sa' => 'Sá',
'Su' => 'Do',
'January' => 'Enero',
'February' => 'Febrero',
'March' => 'Marzo',
'April' => 'Abril',
'May' => 'Mayo',
'June' => 'Junio',
'July' => 'Julio',
'August' => 'Agosto',
'September' => 'Septiembre',
'October' => 'Octubre',
'November' => 'Noviembre',
'December' => 'Diciembre',
];
38 changes: 38 additions & 0 deletions messages/fr/calendar.php
@@ -0,0 +1,38 @@
<?php
/**
* Message translations.
*
* NOTE: this file must be saved in UTF-8 encoding.
*/
return [
'Previous' => 'Précédent',
'Next' => 'Suivant',
'Week' => 'Semaine',
'Monday' => 'Lundi',
'Tuesday' => 'Mardi',
'Wednesday' => 'Mercredi',
'Thursday' => 'Jeudi',
'Friday' => 'Vendredi',
'Saturday' => 'Samedi',
'Sunday' => 'Dimanche',
'W' => 'S',
'Mo' => 'Lu',
'Tu' => 'Ma',
'We' => 'Me',
'Th' => 'Je',
'Fr' => 'Ve',
'Sa' => 'Sa',
'Su' => 'Di',
'January' => 'Janvier',
'February' => 'Février',
'March' => 'Mars',
'April' => 'Avril',
'May' => 'Mai',
'June' => 'Juin',
'July' => 'Juillet',
'August' => 'Août',
'September' => 'Septembre',
'October' => 'Octobre',
'November' => 'Novembre',
'December' => 'Décembre',
];
38 changes: 38 additions & 0 deletions messages/pl/calendar.php
@@ -0,0 +1,38 @@
<?php
/**
* Message translations.
*
* NOTE: this file must be saved in UTF-8 encoding.
*/
return [
'Previous' => 'Poprzedni',
'Next' => 'Następny',
'Week' => 'Tydzień',
'Monday' => 'Poniedziałek',
'Tuesday' => 'Wtorek',
'Wednesday' => 'Środa',
'Thursday' => 'Czwartek',
'Friday' => 'Piątek',
'Saturday' => 'Sobota',
'Sunday' => 'Niedziela',
'W' => 'T',
'Mo' => 'Po',
'Tu' => 'Wt',
'We' => 'Śr',
'Th' => 'Cz',
'Fr' => 'Pi',
'Sa' => 'So',
'Su' => 'Ni',
'January' => 'Styczeń',
'February' => 'Luty',
'March' => 'Marzec',
'April' => 'Kwiecień',
'May' => 'Maj',
'June' => 'Czerwiec',
'July' => 'Lipiec',
'August' => 'Sierpień',
'September' => 'Wrzesień',
'October' => 'Październik',
'November' => 'Listopad',
'December' => 'Grudzień',
];
38 changes: 38 additions & 0 deletions messages/ru/calendar.php
@@ -0,0 +1,38 @@
<?php
/**
* Message translations.
*
* NOTE: this file must be saved in UTF-8 encoding.
*/
return [
'Previous' => 'Предыдущий',
'Next' => 'Следующий',
'Week' => 'Неделю',
'Monday' => 'Понедельник',
'Tuesday' => 'Вторник',
'Wednesday' => 'Среда',
'Thursday' => 'Четверг',
'Friday' => 'Пятница',
'Saturday' => 'Суббота',
'Sunday' => 'Воскресенье',
'W' => 'Н',
'Mo' => 'По',
'Tu' => 'Вт',
'We' => 'Ср',
'Th' => 'Че',
'Fr' => 'Пя',
'Sa' => 'Су',
'Su' => 'Во',
'January' => 'Январь',
'February' => 'Февраль',
'March' => 'Март',
'April' => 'Апрель',
'May' => 'Май',
'June' => 'Июнь',
'July' => 'Июль',
'August' => 'Август',
'September' => 'Сентябрь',
'October' => 'Октября',
'November' => 'Ноябрь',
'December' => 'Декабрь',
];
38 changes: 38 additions & 0 deletions messages/sk/calendar.php
@@ -0,0 +1,38 @@
<?php
/**
* Message translations.
*
* NOTE: this file must be saved in UTF-8 encoding.
*/
return [
'Previous' => 'Predchadzajúci',
'Next' => 'Nasledujúci',
'Week' => 'Týždeň',
'Monday' => 'Pondelok',
'Tuesday' => 'Utorok',
'Wednesday' => 'Streda',
'Thursday' => 'Štvrtok',
'Friday' => 'Piatok',
'Saturday' => 'Sobota',
'Sunday' => 'Nedeľa',
'W' => 'T',
'Mo' => 'Po',
'Tu' => 'Ut',
'We' => 'St',
'Th' => 'Št',
'Fr' => 'Pi',
'Sa' => 'So',
'Su' => 'Ne',
'January' => 'Január',
'February' => 'Február',
'March' => 'Marec',
'April' => 'Apríl',
'May' => 'Máj',
'June' => 'Jún',
'July' => 'Júl',
'August' => 'August',
'September' => 'September',
'October' => 'Október',
'November' => 'November',
'December' => 'December',
];
36 changes: 18 additions & 18 deletions views/month.php
Expand Up @@ -2,30 +2,30 @@
<thead>
<th colspan="8">
<div class="btn-group btn-group-justified">
<a href="" class="navigate btn btn-primary" data-show="<?=$monthRendered-1?>" data-hide="<?=$monthRendered?>">&#8678; Previous</a>
<a href="" class="navigate btn btn-primary" data-show="<?=$monthRendered-1?>" data-hide="<?=$monthRendered?>">&#8678; <?=Yii::t('calendar','Previous')?></a>
<a href="" class="navigate btn btn-primary disabled hidden-xs hidden-sm"><?=$title?></a>
<a href="" class="navigate btn btn-primary disabled hidden-md hidden-lg"><?=$title?></a>
<a href="" class="navigate btn btn-primary" data-show="<?=$monthRendered+1?>" data-hide="<?=$monthRendered?>">Next &#8680;</a>
<a href="" class="navigate btn btn-primary" data-show="<?=$monthRendered+1?>" data-hide="<?=$monthRendered?>"><?=Yii::t('calendar','Next')?> &#8680;</a>
</div>
</th>
</thead>
<thead>
<th class="hidden-xs hidden-sm">Week</th>
<th class="hidden-xs hidden-sm">Monday</th>
<th class="hidden-xs hidden-sm">Tuesday</th>
<th class="hidden-xs hidden-sm">Wednesday</th>
<th class="hidden-xs hidden-sm">Thursday</th>
<th class="hidden-xs hidden-sm">Friday</th>
<th class="hidden-xs hidden-sm">Saturday</th>
<th class="hidden-xs hidden-sm">Sunday</th>
<th class="hidden-md hidden-lg">W</th>
<th class="hidden-md hidden-lg">M</th>
<th class="hidden-md hidden-lg">T</th>
<th class="hidden-md hidden-lg">W</th>
<th class="hidden-md hidden-lg">T</th>
<th class="hidden-md hidden-lg">F</th>
<th class="hidden-md hidden-lg">S</th>
<th class="hidden-md hidden-lg">S</th>
<th class="hidden-xs hidden-sm"><?=Yii::t('calendar','Week')?></th>
<th class="hidden-xs hidden-sm"><?=Yii::t('calendar','Monday')?></th>
<th class="hidden-xs hidden-sm"><?=Yii::t('calendar','Tuesday')?></th>
<th class="hidden-xs hidden-sm"><?=Yii::t('calendar','Wednesday')?></th>
<th class="hidden-xs hidden-sm"><?=Yii::t('calendar','Thursday')?></th>
<th class="hidden-xs hidden-sm"><?=Yii::t('calendar','Friday')?></th>
<th class="hidden-xs hidden-sm"><?=Yii::t('calendar','Saturday')?></th>
<th class="hidden-xs hidden-sm"><?=Yii::t('calendar','Sunday')?></th>
<th class="hidden-md hidden-lg"><?=Yii::t('calendar','W')?></th>
<th class="hidden-md hidden-lg"><?=Yii::t('calendar','Mo')?></th>
<th class="hidden-md hidden-lg"><?=Yii::t('calendar','Tu')?></th>
<th class="hidden-md hidden-lg"><?=Yii::t('calendar','We')?></th>
<th class="hidden-md hidden-lg"><?=Yii::t('calendar','Th')?></th>
<th class="hidden-md hidden-lg"><?=Yii::t('calendar','Fr')?></th>
<th class="hidden-md hidden-lg"><?=Yii::t('calendar','Sa')?></th>
<th class="hidden-md hidden-lg"><?=Yii::t('calendar','Su')?></th>
</thead>

<?=$content?>
Expand Down

0 comments on commit 55357e4

Please sign in to comment.