Skip to content

Commit

Permalink
(refs #1575) add form i18n.
Browse files Browse the repository at this point in the history
  • Loading branch information
ShinichiU committed Sep 12, 2011
1 parent 027d091 commit 7e72736
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 12 deletions.
12 changes: 12 additions & 0 deletions apps/pc_frontend/i18n/messages.ja.xml
Expand Up @@ -250,6 +250,18 @@
<source>Fail to fetch some part of the Calendar.</source>
<target>カレンダーの読み込みに一部失敗しました。</target>
</trans-unit>
<trans-unit id="">
<source>You can not set the end date before start date</source>
<target>終了日時は開始日時より前に設定できません</target>
</trans-unit>
<trans-unit id="">
<source>There is not the resource that you can use</source>
<target>スケジュールリソースに空きがありません</target>
</trans-unit>
<trans-unit id="">
<source>A closed schedule cannot set a resource</source>
<target>非公開のスケジュールでスケジュールリソースは使えません</target>
</trans-unit>
</body>
</file>
</xliff>
34 changes: 22 additions & 12 deletions lib/form/doctrine/PluginScheduleForm.class.php
Expand Up @@ -17,24 +17,34 @@ public function setup()
parent::setup();

$this->generateDateTime();
$members = opCalendarPluginExtension::getAllowedFriendMember(sfContext::getInstance()->getUser()->getMember());
$user = sfContext::getInstance()->getUser();
$members = opCalendarPluginExtension::getAllowedFriendMember($user->getMember());

$this->setWidget('title', new sfWidgetFormInput());

$dateObj = new sfWidgetFormI18nDate(array(
'format' => '%year%年%month%月%day%日',
'culture' => 'ja_JP',
$cul = $user->getCulture();
$dateItems = array(
'culture' => $cul,
'month_format' => 'number',
'years' => $this->dateTime['years'],
));
);
if ('ja_JP' === $cul)
{
$dateItems['format'] = '%year%年%month%月%day%日';
}
$dateObj = new sfWidgetFormI18nDate($dateItems);
$this->setWidget('start_date', $dateObj);
$this->setWidget('end_date', $dateObj);

$timeObj = new sfWidgetFormTime(array(
'with_seconds' => true,
'format' => '%hour%時%minute%分',
$timeItems = array(
'with_seconds' => false,
'minutes' => $this->dateTime['minutes'],
));
);
if ('ja_JP' === $cul)
{
$timeItems['format'] = '%hour%時%minute%分';
}
$timeObj = new sfWidgetFormTime($timeItems);
$this->setWidget('start_time', $timeObj);
$this->setWidget('end_time', $timeObj);
$this->setWidget('public_flag', new sfWidgetFormChoice(array(
Expand All @@ -57,15 +67,15 @@ public function setup()
));
$this->mergePostValidator(new sfValidatorCallback(
array('callback' => array($this, 'validateEndDate')),
array('invalid' => '終了日時は開始日時より前に設定できません')
array('invalid' => 'You can not set the end date before start date')
));
$this->mergePostValidator(new sfValidatorCallback(
array('callback' => array($this, 'validateResourceLock')),
array('invalid' => 'スケジュールリソースに空きがありません')
array('invalid' => 'There is not the resource that you can use')
));
$this->mergePostValidator(new sfValidatorCallback(
array('callback' => array($this, 'validateClosedSchedule')),
array('invalid' => '非公開のスケジュールでスケジュールリソースは使えません')
array('invalid' => 'A closed schedule cannot set a resource')
));

$this->useFields(array('title', 'start_date', 'start_time', 'end_date', 'end_time', 'body', 'public_flag', 'schedule_member'));
Expand Down

0 comments on commit 7e72736

Please sign in to comment.