Skip to content

Commit

Permalink
fixed i18n in schedule module (fixes #1575)
Browse files Browse the repository at this point in the history
  • Loading branch information
nise-nabe committed May 23, 2011
1 parent a2619ca commit 9b57bdb
Show file tree
Hide file tree
Showing 11 changed files with 112 additions and 36 deletions.
34 changes: 31 additions & 3 deletions apps/pc_frontend/i18n/messages.ja.xml
Expand Up @@ -79,11 +79,11 @@
<target>タイトル</target>
</trans-unit>
<trans-unit id="">
<source>Event start</source>
<source>Start</source>
<target>開始日時</target>
</trans-unit>
<trans-unit id="">
<source>Event end</source>
<source>End</source>
<target>終了日時</target>
</trans-unit>
<trans-unit id="">
Expand All @@ -107,7 +107,7 @@
<target>編集</target>
</trans-unit>
<trans-unit id="">
<source>Cancel</source>
<source>Cancel </source>
<target>キャンセル</target>
</trans-unit>
<trans-unit id="">
Expand Down Expand Up @@ -154,6 +154,34 @@
<source>%img1% stands for %f%'s birthday, %img2% stands for event and %img3% stands for joined event.</source>
<target>%img1%は%f%の誕生日、%img2%はイベント、%img3%は参加イベントを意味します。</target>
</trans-unit>
<trans-unit id="">
<source>%1% is required field.</source>
<target>%1%は必須項目です。</target>
</trans-unit>
<trans-unit id="">
<source>Public flag</source>
<target>公開範囲</target>
</trans-unit>
<trans-unit id="">
<source>Schedule author</source>
<target>参加メンバー</target>
</trans-unit>
<trans-unit id="">
<source>Schedule member</source>
<target>参加メンバー</target>
</trans-unit>
<trans-unit id="">
<source>Schedule resource lock%1%</source>
<target>スケジュールリソース%1%</target>
</trans-unit>
<trans-unit id="">
<source>The input has some problem</source>
<target>入力した値に問題があります</target>
</trans-unit>
<trans-unit id="">
<source>Are you sure to delete this schedule?</source>
<target>この予定を削除してよろしいですか?</target>
</trans-unit>
</body>
</file>
</xliff>
Expand Up @@ -7,7 +7,7 @@
<?php if (opGoogleCalendarOAuth::getInstance()->isNeedRedirection()): ?>
&nbsp;<?php echo link_to(__('Enable to Google Calendar\'s permission settings'), '@calendar_api') ?>
<?php else: ?>
&nbsp;<?php echo link_to(__'Add schedule to Google Calendar', '@calendar_api_import') ?>
&nbsp;<?php echo link_to(__('Add schedule to Google Calendar'), '@calendar_api_import') ?>
<?php endif ?>
</p>
</div>
Expand Down
8 changes: 4 additions & 4 deletions apps/pc_frontend/modules/schedule/actions/actions.class.php
Expand Up @@ -67,7 +67,7 @@ public function executeDelete(sfWebRequest $request)
$this->schedule = $this->getRoute()->getObject();
$this->forward404Unless($this->schedule->isEditable($this->getUser()->getMemberId()));
$this->schedule->delete();
$this->getUser()->setFlash('notice', '予定を削除しました。');
$this->getUser()->setFlash('notice', 'The schedule has deleted');
$this->redirect('@calendar');
}

Expand All @@ -89,11 +89,11 @@ public function executeMiniCreate(sfWebRequest $request)
if ($form->isValid())
{
$form->save();
$this->getUser()->setFlash('notice', '予定を追加しました');
$this->getUser()->setFlash('notice', 'The schedule has added');
}
else
{
$this->getUser()->setFlash('error', '入力した値に問題があります');
$this->getUser()->setFlash('error', 'The input has some problem');
}

$this->redirect('@homepage'.$paramstring);
Expand All @@ -109,7 +109,7 @@ protected function processForm(sfWebRequest $request, BaseForm $form)
if ($form->isValid())
{
$schedule = $form->save();
$this->getUser()->setFlash('notice', $form->isNew() ? '予定を追加しました' : '予定を更新しました');
$this->getUser()->setFlash('notice', $form->isNew() ? 'The schedule has added' : 'The schedule has updated');
$results = explode('-', $schedule->start_date);
$this->redirect(sprintf('@calendar_year_month?year=%d&month=%d', $results[0], $results[1]));
}
Expand Down
@@ -1,26 +1,25 @@
<?php use_helper('opCalendar'); ?>
<?php
$startTime = op_format_date($schedule->getStartTime(), 'HH時mm分');
if(!$startTime) $startTime = '--時--分';
$endTime = op_format_date($schedule->getEndTime(), 'HH時mm分');
if(!$endTime) $endTime = '--時--分';
$startTime = op_calendar_format_date($schedule->getStartTime(), 'XTime');
$endTime = op_calendar_format_date($schedule->getEndTime(), 'XTime');
?>
<table class="detailScheduleTable">
<tbody>
<tr class="title"><th>タイトル</th><td><?php echo $schedule->getTitle() ?> (<?php echo $schedule->getPublicFlagLabel() ?>)</td></tr>
<tr class="body"><th>スケジュール作成者</th><td><?php echo op_link_to_member($schedule->getMember()) ?></td></tr>
<tr class="start"><th>開始</th><td><?php echo op_format_date($schedule->getStartDate(), 'yyyy年MM月dd日') ?> <?php echo $startTime ?></td></tr>
<tr class="end"><th>終了</th><td><?php echo op_format_date($schedule->getEndDate(), 'yyyy年MM月dd日') ?> <?php echo $endTime ?></td></tr>
<tr class="title"><th><?php echo __('Title') ?></th><td><?php echo $schedule->getTitle() ?> (<?php echo $schedule->getPublicFlagLabel() ?>)</td></tr>
<tr class="body"><th><?php echo __('Schedule author') ?></th><td><?php echo op_link_to_member($schedule->getMember()) ?></td></tr>
<tr class="start"><th><?php echo __('Start') ?></th><td><?php echo op_calendar_format_date($schedule->getStartDate(), 'XDate') ?> <?php echo $startTime ?></td></tr>
<tr class="end"><th><?php echo __('End') ?></th><td><?php echo op_calendar_format_date($schedule->getEndDate(), 'XDate') ?> <?php echo $endTime ?></td></tr>
<?php if ($schedule->getBody()): ?>
<tr class="body"><th>詳細</th><td><?php echo nl2br($schedule->getBody()) ?></td></tr>
<tr class="body"><th><?php echo __('Detail') ?></th><td><?php echo nl2br($schedule->getBody()) ?></td></tr>
<?php endif ?>
<tr class="members"><th>参加メンバー</th>
<tr class="members"><th><?php echo __('Schedule member') ?></th>
<td>
<?php foreach($sf_data->getRaw('schedule')->getScheduleMembers() as $scheduleMember): ?>
<?php echo op_link_to_member($scheduleMember->Member) ?><br />
<?php endforeach; ?>
</td></tr>
<?php if (count($schedule->ScheduleResourceLocks)): ?>
<tr class="members"><th>スケジュールリソース</th>
<tr class="members"><th><?php echo __('Schedule resource lock') ?></th>
<td>
<?php foreach($schedule->ScheduleResourceLocks as $scheduleResourceLock): ?>
<?php echo $scheduleResourceLock->ScheduleResource->name ?><br />
Expand Down
4 changes: 2 additions & 2 deletions apps/pc_frontend/modules/schedule/templates/_formSchedule.php
Expand Up @@ -11,13 +11,13 @@
<div class="partsHeading"><h3><?php echo $options['title'] ?></h3></div>
<?php echo $form->renderFormTag($options['url']), "\n" ?>
<?php echo $form->renderHiddenFields(), "\n" ?>
<strong>*</strong>は必須項目です。
<?php echo __('%1% is required field.', array('%1%'=>'<strong>*</strong>')) ?>

<?php include_partial('inputScheduleTable', array('form' => $form)) ?>

<div class="operation">
<ul class="moreInfo button">
<li><input type="submit" class="input_submit" value=" 送 信 " /></li>
<li><input type="submit" class="input_submit" value="<?php echo __('Send') ?>" /></li>
</ul>
</div>
</form>
Expand Down
@@ -1,37 +1,37 @@
<table class="inputScheduleTable">
<tr class="title">
<th><label for="schedule_title">タイトル <strong>*</strong></label></th>
<th><label for="schedule_title"><?php echo __('Title') ?> <strong>*</strong></label></th>
<td><?php if ($form['title']->hasError()): ?><?php echo $form['title']->renderError() ?><?php endif; ?>
<?php echo $form['title']->render(array('class' => 'input_text')) ?></td>
</tr>
<tr class="start">
<th><label for="schedule_start_date">開始 <strong>*</strong></label></th>
<th><label for="schedule_start_date"><?php echo __('Start') ?> <strong>*</strong></label></th>
<td><?php if ($form['start_date']->hasError()): ?><?php echo $form['start_date']->renderError() ?>
<?php elseif ($form['start_time']->hasError()): ?><?php echo $form['start_time']->renderError() ?><?php endif; ?>
<?php echo $form['start_date']->render() ?> <?php echo $form['start_time']->render() ?></td>
</tr>
<tr class="end">
<th><label for="schedule_end_date">終了 <strong>*</strong></label></th>
<th><label for="schedule_end_date"><?php echo __('End') ?> <strong>*</strong></label></th>
<td><?php if ($form['end_date']->hasError()): ?><?php echo $form['end_date']->renderError() ?>
<?php elseif ($form['end_time']->hasError()): ?><?php echo $form['end_time']->renderError() ?><?php endif; ?>
<?php echo $form['end_date']->render() ?> <?php echo $form['end_time']->render() ?></td>
</tr>
<tr class="body">
<th><label for="schedule_body">詳細</label></th>
<th><label for="schedule_body"><?php echo __('Detail') ?> </label></th>
<td><?php echo $form['body']->render() ?></td>
</tr>
<tr class="public_flag">
<th><label for="schedule_public_flag">公開範囲 <strong>*</strong></label></th>
<th><label for="schedule_public_flag"><?php echo __('Public flag') ?> <strong>*</strong></label></th>
<td><?php echo $form['public_flag']->render() ?></td>
</tr>
<tr class="schedule_member">
<th><label for="schedule_schedule_member">参加メンバー <strong>*</strong></label></th>
<th><label for="schedule_schedule_member"><?php echo __('Schedule member') ?> <strong>*</strong></label></th>
<td><?php echo $form['schedule_member']->render() ?></td>
</tr>
<?php $max = (int)sfConfig::get('app_schedule_resource_list_max', 5) ?>
<?php for ($i = 1; $i <= $max; $i++): ?>
<tr class="schedule_resource_lock" id="schedule_resource_lock_<?php echo $i ?>">
<th><label for="schedule_schedule_resource_lock_<?php echo $i ?>_id">スケジュールリソース<?php echo $i ?> </label></th>
<th><label for="schedule_schedule_resource_lock_<?php echo $i ?>_id"><?php echo __('Schedule resource lock%1%', array('%1%' => $i)) ?></label></th>
<td><?php echo $form['schedule_resource_lock_'.$i]->render() ?></td>
</tr>
<?php endfor ?>
Expand Down
@@ -1,18 +1,18 @@
<div id="formSchedule" class="dparts form"><div class="parts">
<div class="partsHeading"><h3>この予定を削除してよろしいですか?</h3></div>
<div class="partsHeading"><h3><?php echo __('Are you sure to delete this schedule?')?></h3></div>
<?php include_partial('detailScheduleTable', array('schedule' => $schedule)) ?>

<div class="operation">
<ul class="moreInfo button">
<li>
<form action="<?php echo url_for('schedule_delete', $schedule) ?>" method="post">
<?php echo $form->renderHiddenFields(), "\n" ?>
<input type="submit" class="input_submit" value=" 削 除 " />
<input type="submit" class="input_submit" value="<?php echo __('Delete') ?>" />
</form>
</li>
<li>
<form action="<?php echo url_for('schedule_show', $schedule) ?>" method="get">
<input type="submit" class="input_submit" value="キャンセル" />
<input type="submit" class="input_submit" value="<?php echo __('Cancel ') ?>" />
</form>
</li>
</ul>
Expand Down
@@ -1,5 +1,5 @@
<?php
$options = array();
$options['title'] = '予定を編集する';
$options['title'] = __('Edit schedule');
$options['url'] = url_for('schedule_update', $schedule);
include_partial('formSchedule', array('form' => $form, 'options' => $options));
2 changes: 1 addition & 1 deletion apps/pc_frontend/modules/schedule/templates/newSuccess.php
@@ -1,5 +1,5 @@
<?php
$options = array();
$options['title'] = '予定を追加する';
$options['title'] = __('Add schedule');
$options['url'] = url_for('@schedule_create');
include_partial('formSchedule', array('form' => $form, 'options' => $options));
6 changes: 3 additions & 3 deletions apps/pc_frontend/modules/schedule/templates/showSuccess.php
@@ -1,18 +1,18 @@
<div id="formSchedule" class="dparts form"><div class="parts">
<div class="partsHeading"><h3>予定</h3></div>
<div class="partsHeading"><h3><?php echo __('Schedule') ?></h3></div>
<?php include_partial('detailScheduleTable', array('schedule' => $schedule)) ?>

<?php if ($schedule->isEditable($sf_user->getMemberId())): ?>
<div class="operation">
<ul class="moreInfo button">
<li>
<form action="<?php echo url_for('schedule_edit', $schedule) ?>" method="get">
<input type="submit" class="input_submit" value=" 編 集 " />
<input type="submit" class="input_submit" value="<?php echo __('Edit') ?>" />
</form>
</li>
<li>
<form action="<?php echo url_for('schedule_delete_confirm', $schedule) ?>" method="get">
<input type="submit" class="input_submit" value=" 削 除 " />
<input type="submit" class="input_submit" value="<?php echo __('Delete') ?>" />
</form>
</li>
</ul>
Expand Down
49 changes: 49 additions & 0 deletions lib/helper/opCalendarHelper.php
Expand Up @@ -32,3 +32,52 @@ function get_auther_name($schedule_resource, $link_profile_page = false)

return '';
}

function op_calendar_format_date($date, $format = 'd', $culture = null, $charset = null)
{
if (!$culture)
{
$culture = sfContext::getInstance()->getUser()->getCulture();
}

switch ($format)
{
case 'XTime':
switch ($culture)
{
case 'ja_JP':
$tmpformat = 'HH時mm分';
break;
default:
$tmpformat = 'HH:mm';
break;
}
break;
case 'XDate':
switch ($culture)
{
case 'ja_JP':
$tmpformat = 'yyyy年MM月dd日';
break;
default:
$tmpformat = 'd';
break;
}
break;
}

$result = op_format_date($date, $tmpformat, $calture, $charset);
if (!$result && $format === 'XTime')
{
switch ($culture)
{
case 'ja_JP':
$result = '--時--分';
break;
default:
$result = '--:--';
break;
}
}
return $result;
}

0 comments on commit 9b57bdb

Please sign in to comment.