Fix some of the time-related grammar mistakes

This updates some of the messages to use "For"
instead of "Since" where appropriate.

fixes #5981
This commit is contained in:
Gunnar Beutner 2014-05-29 11:26:02 +02:00
parent e7e7ae72ba
commit d01a98b7e6
9 changed files with 61 additions and 20 deletions

View File

@ -53,7 +53,7 @@ class Documentation
. " --debug Show debug output\n"
. " --help Show help\n"
. " --benchmark Show benchmark summary\n"
. " --watch [s] Refresh output each <s> seconds (default: 5)\n"
. " --watch [s] Refresh output every <s> seconds (default: 5)\n"
;
$d .= "\nShow help on a specific command : icingacli help <command>"
. "\nShow help on a specific module : icingacli help <module>"

View File

@ -101,20 +101,32 @@ class Format
return self::showHourMin($duration);
}
protected static function showHourMin($sec)
protected static function showHourMin($sec, $returnPrefix = false)
{
$min = floor($sec / 60);
if ($min < 60) {
return $min . 'm ' . ($sec % 60) . 's';
if ($returnPrefix) {
return 'For';
} else {
return $min . 'm ' . ($sec % 60) . 's';
}
}
$hour = floor($min / 60);
if ($hour < 24) {
return date('H:i', time() - $sec);
if ($returnPrefix) {
return 'Since';
} else {
return date('H:i', time() - $sec);
}
}
if ($returnPrefix) {
return 'For';
} else {
return floor($hour / 24) . 'd ' . ($hour % 24) . 'h';
}
return floor($hour / 24) . 'd ' . ($hour % 24) . 'h';
}
protected static function smartTimeDiff($diff, $timestamp)
protected static function smartTimeDiff($diff, $timestamp, $returnPrefix = false)
{
if ($timestamp === null || $timestamp === false) {
return '-';
@ -125,15 +137,22 @@ class Format
$prefix = '';
if ($diff < 0) {
$prefix = '-';
$diff *= -1;
}
if ($diff > 3600 * 24 * 3) {
if (abs($diff) > 3600 * 24 * 3) {
if (date('Y') === date('Y', $timestamp)) {
return date('d.m.', $timestamp);
if ($returnPrefix) {
return 'Since';
} else {
return date('d.m.', $timestamp);
}
}
if ($returnPrefix) {
return 'Since';
} else {
return date('m.Y', $timestamp);
}
return date('m.Y', $timestamp);
}
return $prefix . self::showHourMin($diff);
return $prefix . self::showHourMin(abs($diff), $returnPrefix);
}
public static function timeSince($timestamp)
@ -141,11 +160,21 @@ class Format
return self::smartTimeDiff(time() - $timestamp, $timestamp);
}
public static function timeSincePrefix($timestamp)
{
return self::smartTimeDiff(time() - $timestamp, $timestamp, true);
}
public static function timeUntil($timestamp)
{
return self::smartTimeDiff($timestamp - time(), $timestamp);
}
public static function timeUntilPrefix($timestamp)
{
return self::smartTimeDiff($timestamp - time(), $timestamp, true);
}
protected static function formatForUnits($value, & $units, $base)
{
$sign = '';

View File

@ -15,6 +15,12 @@ $this->addHelperFunction('timeSince', function ($timestamp) {
. '</span>';
});
$this->addHelperFunction('timeSincePrefix', function ($timestamp) {
return '<span class="timesince">'
. $this->translate(Format::timeSincePrefix($timestamp))
. ' </span>';
});
$this->addHelperFunction('timeUnless', function ($timestamp) {
if (! $timestamp) return '';
return '<span class="timeunless">'
@ -22,3 +28,9 @@ $this->addHelperFunction('timeUnless', function ($timestamp) {
. '</span>';
});
$this->addHelperFunction('timeUnlessPrefix', function ($timestamp) {
if (! $timestamp) return '';
return '<span class="timeunless">'
. $this->translate(Format::timeUntilPrefix($timestamp))
. '</span>';
});

View File

@ -291,10 +291,11 @@ class ListCommand extends Command
$maxCols - 13
) . "\n";
$out .= sprintf(
" %1s─ %s%s (since %s)",
" %1s─ %s%s (%s %s)",
$leaf,
$screen->underline($row->service_description),
$screen->colorize($utils->objectStateFlags('service', $row) . $perf, 'lightblue'),
strtolower(Format::timeSincePrefix($row->service_last_state_change)),
Format::timeSince($row->service_last_state_change)
);
if ($this->isVerbose) {

View File

@ -78,7 +78,7 @@ if ($hosts->count() === 0) {
<strong><?= ucfirst($helper->monitoringState($host, 'host')); ?></strong><br />
<div class="small-row">
<?= $this->translate('Since') ?> <?= $this->timeSince($host->host_last_state_change); ?>
<?= $this->timeSincePrefix($host->host_last_state_change) ?> <?= $this->timeSince($host->host_last_state_change); ?>
<?php if ($host->host_state > 0): ?>
<br />
<strong><?= ($host->host_state_type === '1') ? $this->translate('Hard') : $this->translate('Soft') ?> </strong> <?= $host->host_current_check_attempt; ?>/<?= $host->host_max_check_attempts; ?>

View File

@ -41,7 +41,7 @@ foreach ($services as $service):
<td class="state" title="<?= $helper->getStateTitle($service, 'service'); ?>">
<strong><?= $this->translate(strtoupper($helper->monitoringState($service, 'service'))) ?></strong><br />
<?php if (!$this->compact): ?><?= $this->translate('Since') ?> <?php endif ?><?= $this->timeSince($service->service_last_state_change); ?>
<?php if (!$this->compact): ?><?= $this->timeSincePrefix($service->service_last_state_change) ?> <?php endif ?><?= $this->timeSince($service->service_last_state_change); ?>
<?php if ($service->service_state > 0 && (int) $service->service_state_type === 0): ?>
<br />
<strong>Soft <?= $service->service_attempt ?></strong>

View File

@ -9,9 +9,8 @@ $cf = $this->getHelper('CommandForm');
?>
<div class="content processinfo">
<p>Backend <strong><?= $this->backendName; ?></strong> is
<?= $ps->is_currently_running === '1' ? sprintf('running with pid %d', $ps->process_id) : 'not running'; ?>
since <?= $this->timeSince($ps->program_start_time); ?>.
<p>Backend <strong><?= $this->backendName; ?></strong>
<?= $ps->is_currently_running === '1' ? sprintf('has been running with PID %d %s ', $ps->process_id, strtolower($this->timeSincePrefix($ps->program_start_time))) . $this->timeSince($ps->program_start_time) : 'is not running'; ?>.
<table class="avp">
<tbody>

View File

@ -6,7 +6,7 @@
<tr class="state <?= $this->monitoringState($object, 'host') ?><?= $object->host_handled ? ' handled' : '' ?>">
<td class="state"<?= $showService ? '' : ' rowspan="2"' ?>>
<?= $this->translate($this->util()->getHostStateName($object->host_state)) ?><br />
<?= $this->translate('Since') ?> <?= $this->timeSince($object->host_last_state_change) ?>
<?= $this->timeSincePrefix($object->host_last_state_change) ?> <?= $this->timeSince($object->host_last_state_change) ?>
</td>
<td><b><?= $this->escape($object->host_name) ?></b><?php
if ($object->host_address && $object->host_address !== $object->host_name): ?>
@ -18,7 +18,7 @@
<tr class="state <?= $this->monitoringState($object, 'service') ?><?= $object->service_handled ? ' handled' : '' ?>">
<td class="state">
<?= $this->translate($this->util()->getServiceStateName($object->service_state)) ?><br />
<?= $this->translate('Since') ?> <?= $this->timeSince($object->service_last_state_change) ?>
<?= $this->timeSincePrefix($object->service_last_state_change) ?> <?= $this->timeSince($object->service_last_state_change) ?>
</td>
<td><b><?= $this->translate('Service') ?>: <?= $this->escape($object->service_description) ?></b>

View File

@ -549,7 +549,7 @@
if (this.failureNotice === null) {
this.failureNotice = this.createNotice(
'error',
'The connection to the Icinga web server has been lost at ' +
'The connection to the Icinga web server was lost at ' +
this.icinga.utils.timeShort() +
'.',
true