Dates localization

This commit is contained in:
Dmitry Khomutov 2017-01-15 17:28:15 +07:00
commit d0a46ee8ab
No known key found for this signature in database
GPG key ID: 7EB36C9576F9ECB9
17 changed files with 35 additions and 106 deletions

View file

@ -237,10 +237,12 @@ class BuildController extends Controller
if (!$build) {
$response->setResponseCode(404);
$response->setContent([]);
return $response;
}
$response->setContent($this->getBuildData($build));
return $response;
}
@ -257,6 +259,7 @@ class BuildController extends Controller
$response = new JsonResponse();
$response->setContent($data);
return $response;
}

View file

@ -194,24 +194,4 @@ class Lang
}
}
}
/**
* Create a time tag for localization.
*
* See http://momentjs.com/docs/#/displaying/format/ for a list of supported formats.
*
* @param \DateTime $dateTime The dateTime to represent.
* @param string $format The moment.js format to use.
*
* @return string The formatted tag.
*/
public static function formatDateTime(\DateTime $dateTime, $format = 'lll')
{
return sprintf(
'<time datetime="%s" data-format="%s">%s</time>',
$dateTime->format(\DateTime::ISO8601),
$format,
$dateTime->format(\DateTime::RFC2822)
);
}
}

View file

@ -213,7 +213,8 @@ PHP Censor',
'codeception_time' => 'Time',
'codeception_synopsis' => '<strong>%1$d</strong> tests carried out in <strong>%2$f</strong> seconds.
<strong>%3$d</strong> failures.',
'suite' => 'Suite',
'test' => 'Test',
'file' => 'File',
'line' => 'Line',
'class' => 'Class',

View file

@ -204,6 +204,8 @@ PHP Censor',
'codeception_time' => 'Время',
'codeception_synopsis' => 'Тестов выполнено: <strong>%1$d</strong> (за <strong>%2$f</strong> сек.). Провалов: <strong>%3$d</strong>.',
'suite' => 'Набор',
'test' => 'Тест',
'file' => 'Файл',
'line' => 'Строка',
'class' => 'Класс',

View file

@ -32,8 +32,8 @@
<tr>
<th><?php Lang::out('duration'); ?></th>
<td style="text-align: right" class="build-duration duration" data-duration="<?php print $build->getDuration(); ?>">
<td style="text-align: right" class="build-duration duration">
<?php print $build->getDuration(); ?> <?= Lang::get('seconds'); ?>
</td>
</tr>
</table>
@ -89,20 +89,22 @@
<table class="table">
<tr>
<th><?php Lang::out('created'); ?></th>
<td style="text-align: right" class="build-created datetime" data-date="<?php print $build->getCreated() ? $build->getCreated()->format('Y-m-d H:i:s') : ''; ?>">
<td style="text-align: right" class="build-created datetime">
<?php print $build->getCreated() ? $build->getCreated()->format('Y-m-d H:i:s') : ''; ?>
</td>
</tr>
<tr>
<th><?php Lang::out('started'); ?></th>
<td style="text-align: right" class="build-started datetime" data-date="<?php print $build->getStarted() ? $build->getStarted()->format('Y-m-d H:i:s') : ''; ?>">
<td style="text-align: right" class="build-started datetime">
<?php print $build->getStarted() ? $build->getStarted()->format('Y-m-d H:i:s') : ''; ?>
</td>
</tr>
<tr>
<th><?php Lang::out('finished'); ?></th>
<td style="text-align: right" class="build-finished datetime" data-date="<?php print $build->getFinished() ? $build->getFinished()->format('Y-m-d H:i:s') : ''; ?>">
<td style="text-align: right" class="build-finished datetime">
<?php print $build->getFinished() ? $build->getFinished()->format('Y-m-d H:i:s') : ''; ?>
</td>
</tr>
</table>
@ -170,7 +172,7 @@
<?php
foreach ($plugins as $plugin) {
print '<script src="'.APP_URL.'assets/js/build-plugins/' . $plugin . '"></script>' . PHP_EOL;
print '<script src="' . APP_URL . 'assets/js/build-plugins/' . $plugin . '"></script>' . PHP_EOL;
}
?>

View file

@ -18,7 +18,6 @@
<script src="<?php print APP_URL; ?>assets/vendor/admin-lte/plugins/jQuery/jquery-2.2.3.min.js"></script>
<script src="<?php print APP_URL; ?>assets/js/class.js"></script>
<script src="<?php print APP_URL; ?>assets/vendor/sprintf-js/dist/sprintf.min.js"></script>
<script src="<?php print APP_URL; ?>assets/vendor/moment/min/moment-with-locales.min.js"></script>
<script src="<?php print APP_URL; ?>assets/js/app.js" type="text/javascript"></script>
</head>
<body class="hold-transition skin-black layout-top-nav">

View file

@ -39,12 +39,12 @@ if (count($builds)) {
break;
case 2:
$statuses[] = 'ok';
$success = is_null($success) && !is_null($build->getFinished()) ? Lang::formatDateTime($build->getFinished()) : $success;
$success = is_null($success) && !is_null($build->getFinished()) ? $build->getFinished()->format('Y-m-d H:i:s') : $success;
break;
case 3:
$failures++;
$statuses[] = 'failed';
$failure = is_null($failure) && !is_null($build->getFinished()) ? Lang::formatDateTime($build->getFinished()) : $failure;
$failure = is_null($failure) && !is_null($build->getFinished()) ? $build->getFinished()->format('Y-m-d H:i:s') : $failure;
break;
}
}
@ -62,7 +62,7 @@ if ($buildCount > 0) {
$message = Lang::get('x_of_x_failed', $failures, $buildCount);
if (!is_null($lastSuccess) && !is_null($lastSuccess->getFinished())) {
$message .= Lang::get('last_successful_build', Lang::formatDateTime($lastSuccess->getFinished()));
$message .= Lang::get('last_successful_build', $lastSuccess->getFinished()->format('Y-m-d H:i:s'));
} else {
$message .= Lang::get('never_built_successfully');
}
@ -71,7 +71,7 @@ if ($buildCount > 0) {
$shortMessage = Lang::get('all_builds_passed_short', $buildCount, $buildCount);
if (!is_null($lastFailure) && !is_null($lastFailure->getFinished())) {
$message .= Lang::get('last_failed_build', Lang::formatDateTime($lastFailure->getFinished()));
$message .= Lang::get('last_failed_build', $lastFailure->getFinished()->format('Y-m-d H:i:s'));
} else {
$message .= Lang::get('never_failed_build');
}

View file

@ -38,7 +38,7 @@
?>
<li class="time-label">
<span class="bg-gray">
<?php print Lang::formatDateTime($last, 'll'); ?>
<?= $last->format('Y-m-d'); ?>
</span>
</li>
<?php endif; ?>
@ -48,7 +48,7 @@
<li>
<i class="fa fa-<?php print $build->getProject()->getIcon(); ?> bg-<?php print $color; ?>"></i>
<div class="timeline-item">
<span class="time"><i class="fa fa-clock-o"></i> <?php print Lang::formatDateTime($updated, 'LT'); ?></span>
<span class="time"><i class="fa fa-clock-o"></i> <?= $updated->format('H:i:s'); ?></span>
<h3 class="timeline-header">
<a href="<?php print APP_URL; ?>project/view/<?php print $build->getProjectId(); ?>">
<?php print $build->getProject()->getTitle(); ?>

View file

@ -40,12 +40,12 @@ foreach($projects as $project):
break;
case 2:
$statuses[] = 'ok';
$success = is_null($success) && !is_null($build->getFinished()) ? Lang::formatDateTime($build->getFinished()) : $success;
$success = is_null($success) && !is_null($build->getFinished()) ? $build->getFinished()->format('Y-m-d H:i:s') : $success;
break;
case 3:
$failures++;
$statuses[] = 'failed';
$failure = is_null($failure) && !is_null($build->getFinished()) ? Lang::formatDateTime($build->getFinished()) : $failure;
$failure = is_null($failure) && !is_null($build->getFinished()) ? $build->getFinished()->format('Y-m-d H:i:s') : $failure;
break;
}
}
@ -63,7 +63,7 @@ foreach($projects as $project):
$message = Lang::get('x_of_x_failed', $failures, $buildCount);
if (!is_null($lastSuccess) && !is_null($lastSuccess->getFinished())) {
$message .= Lang::get('last_successful_build', Lang::formatDateTime($lastSuccess->getFinished()));
$message .= Lang::get('last_successful_build', $lastSuccess->getFinished()->format('Y-m-d H:i:s'));
} else {
$message .= Lang::get('never_built_successfully');
}
@ -72,7 +72,7 @@ foreach($projects as $project):
$shortMessage = Lang::get('all_builds_passed_short', $buildCount, $buildCount);
if (!is_null($lastFailure) && !is_null($lastFailure->getFinished())) {
$message .= Lang::get('last_failed_build', Lang::formatDateTime($lastFailure->getFinished()));
$message .= Lang::get('last_failed_build', $lastFailure->getFinished()->format('Y-m-d H:i:s'));
} else {
$message .= Lang::get('never_failed_build');
}

View file

@ -64,7 +64,7 @@
?>
<li class="time-label">
<span class="bg-gray">
<?php print Lang::formatDateTime($last, 'll'); ?>
<?= $last->format('Y-m-d'); ?>
</span>
</li>
<?php endif; ?>
@ -74,7 +74,7 @@
<li>
<i class="fa fa-<?php print $build->getProject()->getIcon(); ?> bg-<?php print $color; ?>"></i>
<div class="timeline-item">
<span class="time"><i class="fa fa-clock-o"></i> <?php print Lang::formatDateTime($updated, 'LT'); ?></span>
<span class="time"><i class="fa fa-clock-o"></i> <?= $updated->format('H:i:s'); ?></span>
<h3 class="timeline-header">
<a href="<?php print APP_URL; ?>project/view/<?php print $build->getProjectId(); ?>">
<?php print $build->getProject()->getTitle(); ?>

View file

@ -30,7 +30,6 @@
<script src="<?php print APP_URL; ?>assets/vendor/admin-lte/plugins/jQuery/jquery-2.2.3.min.js"></script>
<script src="<?php print APP_URL; ?>assets/js/class.js"></script>
<script src="<?php print APP_URL; ?>assets/vendor/sprintf-js/dist/sprintf.min.js"></script>
<script src="<?php print APP_URL; ?>assets/vendor/moment/min/moment-with-locales.min.js"></script>
<script src="<?php print APP_URL; ?>assets/js/app.js" type="text/javascript"></script>
</head>