diff options
author | emkael <emkael@tlen.pl> | 2016-06-12 17:25:32 +0200 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2016-06-12 17:25:32 +0200 |
commit | ece88ff6d4c59418dc043c735252aca012eee207 (patch) | |
tree | cfaa9686077952a0ee45e530c9b469ace704a643 /app/frontend | |
parent | b1458fd1f8c871ba58976eb079caabc60ae2d275 (diff) |
* localizing DB strings
Diffstat (limited to 'app/frontend')
-rw-r--r-- | app/frontend/dto/BaseDTO.php | 15 | ||||
-rw-r--r-- | app/frontend/dto/CalendarDTO.php | 8 | ||||
-rw-r--r-- | app/frontend/dto/CalendarGroupDTO.php | 8 | ||||
-rw-r--r-- | app/frontend/dto/EventDTO.php | 8 |
4 files changed, 33 insertions, 6 deletions
diff --git a/app/frontend/dto/BaseDTO.php b/app/frontend/dto/BaseDTO.php new file mode 100644 index 0000000..ccb9df5 --- /dev/null +++ b/app/frontend/dto/BaseDTO.php @@ -0,0 +1,15 @@ +<?php + +class BaseDTO { + + public static function getTranslation(string $string, string $category) { + $module = Prado::getApplication()->getModule('db-strings'); + if (!$module) { + return $string; + } + return $module->getTranslation($string, $category); + } + +} + +?> diff --git a/app/frontend/dto/CalendarDTO.php b/app/frontend/dto/CalendarDTO.php index 4468941..18b3767 100644 --- a/app/frontend/dto/CalendarDTO.php +++ b/app/frontend/dto/CalendarDTO.php @@ -1,8 +1,9 @@ <?php +Prado::using('Application.dto.BaseDTO'); Prado::using('Application.model.Calendar'); -class CalendarDTO { +class CalendarDTO extends BaseDTO { public $ID; public $Name; @@ -14,7 +15,10 @@ class CalendarDTO { public function loadRecord(Calendar $calendarRecord) { $this->ID = $calendarRecord->UID; - $this->Name = $calendarRecord->CustomName ?: $calendarRecord->Name; + $this->Name = self::getTranslation( + $calendarRecord->CustomName ?: $calendarRecord->Name, + 'Calendar.Name' + ); $this->Website = $calendarRecord->Website; $this->Image = $calendarRecord->CustomImageUrl; $this->Url = $calendarRecord->CustomUrl; diff --git a/app/frontend/dto/CalendarGroupDTO.php b/app/frontend/dto/CalendarGroupDTO.php index 7b64c6e..a607826 100644 --- a/app/frontend/dto/CalendarGroupDTO.php +++ b/app/frontend/dto/CalendarGroupDTO.php @@ -1,9 +1,10 @@ <?php +Prado::using('Application.dto.BaseDTO'); Prado::using('Application.model.Category'); Prado::using('Application.dto.CalendarDTO'); -class CalendarGroupDTO { +class CalendarGroupDTO extends BaseDTO { public $Name; public $ID; @@ -11,7 +12,10 @@ class CalendarGroupDTO { public $Calendars = []; public function loadRecord(Category $categoryRecord, array $calendars) { - $this->Name = $categoryRecord->Name; + $this->Name = self::getTranslation( + $categoryRecord->Name, + 'CalendarGroup.Name' + ); $this->ID = $categoryRecord->ID; $this->Priority = $categoryRecord->Priority; $this->Calendars = array_map( diff --git a/app/frontend/dto/EventDTO.php b/app/frontend/dto/EventDTO.php index 8f5cdf5..9af06e4 100644 --- a/app/frontend/dto/EventDTO.php +++ b/app/frontend/dto/EventDTO.php @@ -1,10 +1,11 @@ <?php +Prado::using('Application.dto.BaseDTO'); Prado::using('Application.model.Entry'); Prado::using('Application.dto.CalendarDTO'); Prado::using('Application.facades.UserFacade'); -class EventDTO { +class EventDTO extends BaseDTO { public $DateString; public $Name; @@ -45,7 +46,10 @@ class EventDTO { } public function loadRecord(Entry $event, array $calendars) { - $this->Name = $event->Name; + $this->Name = self::getTranslation( + $event->Name, + 'Event.Name' + ); $this->Location = $event->Location; if ($event->AllDay) { |