Add missing/refactor existing localization markings

This commit is contained in:
Johannes Meyer 2020-04-17 18:41:33 +02:00
parent a94073e540
commit dba06b2eab
43 changed files with 270 additions and 225 deletions

View file

@ -67,7 +67,7 @@ class ConfigController extends Controller
}
if ($form->save()) {
$this->translate('Command transport successfully created');
Notification::success($this->translate('Command transport successfully created'));
return true;
}

View file

@ -78,7 +78,8 @@ class ErrorController extends IcingaErrorController
$this->setParam('error_handler', null);
}
$heading = Html::tag('h2', 'Database not configured');
// TODO: Find a native way for ipl-html to support enriching text with html
$heading = Html::tag('h2', $this->translate('Database not configured'));
$intro = Html::tag('p', ['data-base-target' => '_next'], Html::sprintf(
'You seem to not have configured a resource for Icinga DB yet. Please %s and then tell Icinga DB Web %s.',
new Link(

View file

@ -35,11 +35,10 @@ class HealthController extends Controller
$instance = $instance->first();
if ($instance === null) {
$this->addContent(Html::tag(
'p',
$this->addContent(Html::tag('p', $this->translate(
'It seems that Icinga DB is not running.'
. ' Make sure Icinga DB is running and writing into the database.'
));
)));
return;
}
@ -52,27 +51,27 @@ class HealthController extends Controller
$this->addContent(new Health($instance));
$this->addContent(Html::tag('section', ['class' => 'check-summary'], [
Html::tag('div', ['class' => 'col'], [
Html::tag('h3', 'Host Checks'),
Html::tag('h3', $this->translate('Host Checks')),
Html::tag('div', ['class' => 'col-content'], [
new VerticalKeyValue(
'Active',
$this->translate('Active'),
$hoststateSummary->hosts_active_checks_enabled
),
new VerticalKeyValue(
'Passive',
$this->translate('Passive'),
$hoststateSummary->hosts_passive_checks_enabled
)
])
]),
Html::tag('div', ['class' => 'col'], [
Html::tag('h3', 'Service Checks'),
Html::tag('h3', $this->translate('Service Checks')),
Html::tag('div', ['class' => 'col-content'], [
new VerticalKeyValue(
'Active',
$this->translate('Active'),
$servicestateSummary->services_active_checks_enabled
),
new VerticalKeyValue(
'Passive',
$this->translate('Passive'),
$servicestateSummary->services_passive_checks_enabled
)
])
@ -82,7 +81,7 @@ class HealthController extends Controller
$featureCommands = Html::tag(
'section',
['class' => 'instance-commands'],
Html::tag('h2', 'Feature Commands')
Html::tag('h2', $this->translate('Feature Commands'))
);
$programStatus = (object) [
'active_host_checks_enabled' => $instance->icinga2_active_host_checks_enabled,

View file

@ -72,7 +72,7 @@ class HistoryController extends Controller
$url->setParam('page', $page + 1)
->setAnchor('page-' . ($page + 1))
))
->setLabel('Load More')
->setLabel($this->translate('Load More'))
->setAttribute('data-no-icinga-ajax', true);
$this->addControl($sortControl);

View file

@ -163,7 +163,7 @@ class HostController extends Controller
$url->setParam('page', $page + 1)
->setAnchor('page-' . ($page + 1))
))
->setLabel('Load More')
->setLabel($this->translate('Load More'))
->setAttribute('data-no-icinga-ajax', true);
$this->addControl((new HostList([$this->host]))->setViewMode('minimal'));

View file

@ -163,7 +163,7 @@ class ServiceController extends Controller
$url->setParam('page', $page + 1)
->setAnchor('page-' . ($page + 1))
))
->setLabel('Load More')
->setLabel($this->translate('Load More'))
->setAttribute('data-no-icinga-ajax', true);
$this->addControl((new ServiceList([$this->service]))->setViewMode('minimal'));

View file

@ -32,7 +32,7 @@ class StaticController extends Controller
$filePath = realpath($moduleRoot . '/public/' . rawurldecode($file));
if ($filePath === false) {
$this->httpNotFound('%s does not exist', $filePath);
$this->httpNotFound($this->translate('%s does not exist'), $filePath);
}
$s = stat($filePath);

View file

@ -19,7 +19,7 @@ class UserController extends Controller
public function init()
{
if (! $this->hasPermission('*') && $this->hasPermission('no-monitoring/contacts')) {
throw new SecurityException('No permission for %s', 'monitoring/contacts');
throw new SecurityException($this->translate('No permission for %s'), 'monitoring/contacts');
}
$this->setTitle($this->translate('User'));
@ -44,22 +44,22 @@ class UserController extends Controller
{
$this->addControl(new UserList([$this->user]));
$this->addContent(Html::tag('h2', 'Details'));
$this->addContent(Html::tag('h2', $this->translate('Details')));
$this->addContent(Html::tag('ul', ['class' => 'key-value-list'], [
Html::tag('li', [
Html::tag('span', ['class' => 'label'], 'E-Mail'),
Html::tag('span', ['class' => 'label'], $this->translate('E-Mail')),
Html::tag(
'span',
['class' => 'value'],
$this->user->email ?: Html::tag('span', ['class' => 'text-muted'], 'Unset')
$this->user->email ?: Html::tag('span', ['class' => 'text-muted'], $this->translate('Unset'))
)
]),
Html::tag('li', [
Html::tag('span', ['class' => 'label'], 'Pager'),
Html::tag('span', ['class' => 'label'], $this->translate('Pager')),
Html::tag(
'span',
['class' => 'value'],
$this->user->pager ?: Html::tag('span', ['class' => 'text-muted'], 'Unset')
$this->user->pager ?: Html::tag('span', ['class' => 'text-muted'], $this->translate('Unset'))
)
])
]));

View file

@ -19,7 +19,7 @@ class UsergroupController extends Controller
public function init()
{
if (! $this->hasPermission('*') && $this->hasPermission('no-monitoring/contacts')) {
throw new SecurityException('No permission for %s', 'monitoring/contacts');
throw new SecurityException($this->translate('No permission for %s'), 'monitoring/contacts');
}
$this->setTitle($this->translate('User Group'));

View file

@ -16,7 +16,7 @@ class UsergroupsController extends Controller
parent::init();
if (! $this->hasPermission('*') && $this->hasPermission('no-monitoring/contacts')) {
throw new SecurityException('No permission for %s', 'monitoring/contacts');
throw new SecurityException($this->translate('No permission for %s'), 'monitoring/contacts');
}
}

View file

@ -16,7 +16,7 @@ class UsersController extends Controller
parent::init();
if (! $this->hasPermission('*') && $this->hasPermission('no-monitoring/contacts')) {
throw new SecurityException('No permission for %s', 'monitoring/contacts');
throw new SecurityException($this->translate('No permission for %s'), 'monitoring/contacts');
}
}

View file

@ -22,7 +22,7 @@ class DatabaseConfigForm extends ConfigForm
'description' => $this->translate('Database resource'),
'label' => $this->translate('Database'),
'multiOptions' => array_merge(
['' => ' - Please choose - '],
['' => sprintf(' - %s - ', $this->translate('Please choose'))],
array_combine($dbResources, $dbResources)
),
'disable' => [''],

View file

@ -95,19 +95,19 @@ class HostStates
{
switch (true) {
case $state === self::UP:
$text = mt('icingadb', 'up');
$text = t('up');
break;
case $state === self::DOWN:
$text = mt('icingadb', 'down');
$text = t('down');
break;
case $state === self::UNREACHABLE:
$text = mt('icingadb', 'unreachable');
$text = t('unreachable');
break;
case $state === self::PENDING:
$text = mt('icingadb', 'pending');
$text = t('pending');
break;
case $state === null:
$text = mt('icingadb', 'not available');
$text = t('not available');
break;
default:
throw new \InvalidArgumentException(sprintf('Invalid host state %d', $state));

View file

@ -103,22 +103,22 @@ class ServiceStates
{
switch (true) {
case $state === self::OK:
$text = mt('icingadb', 'ok');
$text = t('ok');
break;
case $state === self::WARNING:
$text = mt('icingadb', 'warning');
$text = t('warning');
break;
case $state === self::CRITICAL:
$text = mt('icingadb', 'critical');
$text = t('critical');
break;
case $state === self::UNKNOWN:
$text = mt('icingadb', 'unknown');
$text = t('unknown');
break;
case $state === self::PENDING:
$text = mt('icingadb', 'pending');
$text = t('pending');
break;
case $state === null:
$text = mt('icingadb', 'not available');
$text = t('not available');
break;
default:
throw new \InvalidArgumentException(sprintf('Invalid service state %d', $state));

View file

@ -54,10 +54,7 @@ class MonitoringRestrictions
$restriction->addFilter(Filter::fromQueryString($filter));
} catch (QueryException $e) {
throw new ConfigurationError(
mt(
'monitoring',
'Cannot apply restriction %s using the filter %s. You can only use the following columns: %s'
),
t('Cannot apply restriction %s using the filter %s. You can only use the following columns: %s'),
$name,
$filter,
implode(', ', array(

View file

@ -20,6 +20,7 @@ class DateFormatter
$seconds = $seconds + (3600 - ($seconds % 3600));
}
// TODO: tranlsation necessary?
$minutes = floor((float) $seconds / 60);
if ($minutes < 60) {
$formatted = sprintf('%dm %ds', $minutes, $seconds % 60);

View file

@ -39,8 +39,7 @@ class ApplicationState extends ApplicationStateHook
$this->addError(
'icingadb/no-instance',
$noInstanceSince,
mt(
'icingadb',
t(
'It seems that Icinga DB is not running.'
. ' Make sure Icinga DB is running and writing into the database.'
)
@ -52,8 +51,7 @@ class ApplicationState extends ApplicationStateHook
$this->addError(
'icingadb/icingadb-down',
$instance->heartbeat,
mt(
'icingadb',
t(
'It seems that Icinga DB is not running.'
. ' Make sure Icinga DB is running and writing into the database.'
)
@ -92,10 +90,7 @@ class ApplicationState extends ApplicationStateHook
$this->addError(
'icingadb/redis-outdated',
$lastIcingaHeartbeat,
mt(
'icingadb',
'Icinga Redis is outdated. Make sure Icinga 2 is running and connected to Redis.'
)
t('Icinga Redis is outdated. Make sure Icinga 2 is running and connected to Redis.')
);
break;
@ -113,7 +108,7 @@ class ApplicationState extends ApplicationStateHook
$this->addError(
'icingadb/redis-down',
$downSince,
mt('icingadb', sprintf("Can't connect to Icinga Redis: %s", $e->getMessage()))
sprintf(t("Can't connect to Icinga Redis: %s"), $e->getMessage())
);
}
}

View file

@ -80,7 +80,7 @@ abstract class BaseItemList extends BaseHtmlElement
if ($this->isEmpty()) {
$this->setTag('div');
$this->add(new EmptyState('No items found.'));
$this->add(new EmptyState(t('No items found.')));
}
}
}

View file

@ -17,7 +17,8 @@ abstract class BaseServiceListItem extends StateListItem
{
protected function createSubject()
{
return [
return [Html::sprintf(
t('%s on %s', '<service> on <host>'),
Html::tag(
'a',
[
@ -26,7 +27,6 @@ abstract class BaseServiceListItem extends StateListItem
],
$this->item->display_name
),
' on ',
Html::tag(
'a',
[
@ -39,7 +39,7 @@ abstract class BaseServiceListItem extends StateListItem
$this->item->host->display_name
]
)
];
)];
}
protected function init()

View file

@ -29,7 +29,7 @@ class ContinueWith implements ValidHtml
}
$continue = new ActionLink(
'Continue with filter',
t('Continue with filter'),
$this->url->setQueryString($this->filter->toQueryString()),
'forward',
['class' => 'continue-with', 'data-base-target' => '_next']

View file

@ -69,7 +69,7 @@ class CheckStatistics extends Card
$now = Html::tag('li', [
'class' => 'bubble now',
'style' => sprintf('left: %F%%', $hPadding + $leftNow),
], Html::tag('strong', 'Now'));
], Html::tag('strong', t('Now')));
$above->add($now);
$markerLast = Html::tag('div', [
@ -99,9 +99,9 @@ class CheckStatistics extends Card
$lastUpdate = Html::tag(
'li',
['class' => 'bubble upwards last'],
new VerticalKeyValue('Last update', $this->object->state->last_update !== null
new VerticalKeyValue(t('Last update'), $this->object->state->last_update !== null
? new TimeAgo($this->object->state->last_update)
: 'PENDING')
: t('PENDING'))
);
$interval = Html::tag(
'li',
@ -112,10 +112,10 @@ class CheckStatistics extends Card
'li',
['class' => 'bubble upwards next'],
$this->object->state->is_overdue
? new VerticalKeyValue('Overdue', new TimeSince($nextCheckTime))
? new VerticalKeyValue(t('Overdue'), new TimeSince($nextCheckTime))
: new VerticalKeyValue(
'Next Check',
$nextCheckTime !== null ? new TimeUntil($nextCheckTime) : 'PENDING'
t('Next Check'),
$nextCheckTime !== null ? new TimeUntil($nextCheckTime) : t('PENDING')
)
);
@ -152,14 +152,17 @@ class CheckStatistics extends Card
];
$header->add([
new VerticalKeyValue('Command', $this->object->checkcommand),
new VerticalKeyValue(t('Command'), $this->object->checkcommand),
new VerticalKeyValue(
'Attempts',
t('Attempts'),
new CheckAttempt($this->object->state->attempt, $this->object->max_check_attempts)
),
new VerticalKeyValue('Check source', $checkSource),
new VerticalKeyValue('Execution time', Format::seconds($this->object->state->execution_time)),
new VerticalKeyValue('Latency', Format::seconds($this->object->state->latency))
new VerticalKeyValue(t('Check source'), $checkSource),
new VerticalKeyValue(
t('Execution time'),
Format::seconds($this->object->state->execution_time)
),
new VerticalKeyValue(t('Latency'), Format::seconds($this->object->state->latency))
]);
}
}

View file

@ -38,7 +38,7 @@ class CommentDetail extends BaseHtmlElement
protected function createComment()
{
return [
Html::tag('h2', 'Comment'),
Html::tag('h2', t('Comment')),
new MarkdownText($this->comment->text)
];
}
@ -50,16 +50,19 @@ class CommentDetail extends BaseHtmlElement
if ($this->comment->expire_time != 0) {
$details[] = Html::tag(
'p',
['This acknowledgement expires', ' ', new TimeUntil($this->comment->expire_time), '.']
Html::sprintf(
t('This acknowledgement expires %s.', '..<time-until>'),
new TimeUntil($this->comment->expire_time)
)
);
}
if ($this->comment->is_sticky) {
$details[] = Html::tag('p', 'This acknowledgement is sticky.');
$details[] = Html::tag('p', t('This acknowledgement is sticky.'));
}
if (! empty($details)) {
array_unshift($details, Html::tag('h2', 'Details'));
array_unshift($details, Html::tag('h2', t('Details')));
}
return $details;
@ -88,7 +91,7 @@ class CommentDetail extends BaseHtmlElement
$submitButton = $removeCommentForm->getElement('btn_submit');
$submitButton->content = (new HtmlDocument())
->add([new Icon('trash'), 'Remove Comment'])
->add([new Icon('trash'), t('Remove Comment')])
->setSeparator(' ')
->render();

View file

@ -45,7 +45,8 @@ class CustomVarTable extends BaseHtmlElement
protected function renderArray($name, array $array)
{
$this->addRow("$name (Array)", count($array) . ' items');
$numItems = count($array);
$this->addRow("$name (Array)", sprintf(tp('%d item', '%d items', $numItems), $numItems));
++$this->level;
@ -58,7 +59,8 @@ class CustomVarTable extends BaseHtmlElement
protected function renderObject($name, $object)
{
$this->addRow($name, count(get_object_vars($object)) . ' items');
$numItems = count(get_object_vars($object));
$this->addRow($name, sprintf(tp('%d item', '%d items', $numItems), $numItems));
++$this->level;

View file

@ -119,7 +119,10 @@ class DowntimeCard extends BaseHtmlElement
Html::tag(
'li',
['class' => 'bubble start'],
new VerticalKeyValue('Scheduled Start', new TimeAgo($this->downtime->scheduled_start_time))
new VerticalKeyValue(
t('Scheduled Start'),
new TimeAgo($this->downtime->scheduled_start_time)
)
),
Html::tag(
'li',
@ -130,7 +133,7 @@ class DowntimeCard extends BaseHtmlElement
$hPadding + $this->calcRelativeLeft($this->downtime->scheduled_end_time)
)
],
new VerticalKeyValue('Scheduled End', $endTime)
new VerticalKeyValue(t('Scheduled End'), $endTime)
)
]);
@ -141,7 +144,7 @@ class DowntimeCard extends BaseHtmlElement
'class' => 'bubble upwards start' . ($evade ? ' left' : ''),
'style' => sprintf('left: %F%%', $flexStartLeft)
],
new VerticalKeyValue('Start', new TimeAgo($this->downtime->start_time))
new VerticalKeyValue(t('Start'), new TimeAgo($this->downtime->start_time))
),
Html::tag(
'li',
@ -149,7 +152,7 @@ class DowntimeCard extends BaseHtmlElement
'class' => 'bubble upwards end' . ($evade ? ' right' : ''),
'style' => sprintf('left: %F%%', $flexEndLeft)
],
new VerticalKeyValue('End', new TimeUntil($this->downtime->end_time))
new VerticalKeyValue(t('End'), new TimeUntil($this->downtime->end_time))
)
]);
} elseif ($this->downtime->is_flexible) {
@ -168,7 +171,10 @@ class DowntimeCard extends BaseHtmlElement
Html::tag(
'li',
['class' => 'bubble start'],
new VerticalKeyValue('Scheduled Start', new TimeAgo($this->downtime->scheduled_start_time))
new VerticalKeyValue(
t('Scheduled Start'),
new TimeAgo($this->downtime->scheduled_start_time)
)
),
Html::tag(
'li',
@ -179,7 +185,7 @@ class DowntimeCard extends BaseHtmlElement
$hPadding + $this->calcRelativeLeft($this->downtime->scheduled_end_time)
)
],
new VerticalKeyValue('Scheduled End', $endTime)
new VerticalKeyValue(t('Scheduled End'), $endTime)
)
]);
@ -204,7 +210,7 @@ class DowntimeCard extends BaseHtmlElement
$hPadding + $this->calcRelativeLeft($this->downtime->scheduled_start_time)
)
],
new VerticalKeyValue('Start', new TimeAgo($this->downtime->scheduled_start_time))
new VerticalKeyValue(t('Start'), new TimeAgo($this->downtime->scheduled_start_time))
),
Html::tag(
'li',
@ -215,7 +221,7 @@ class DowntimeCard extends BaseHtmlElement
$hPadding + $this->calcRelativeLeft($this->downtime->scheduled_end_time)
)
],
new VerticalKeyValue('End', new TimeUntil($this->downtime->scheduled_end_time))
new VerticalKeyValue(t('End'), new TimeUntil($this->downtime->scheduled_end_time))
)
]);
}
@ -229,7 +235,7 @@ class DowntimeCard extends BaseHtmlElement
$hPadding + $this->calcRelativeLeft(time(), null, null, -$hPadding + 3)
)
],
Html::tag('strong', 'Now')
Html::tag('strong', t('Now'))
);
$above->add($now);

View file

@ -93,7 +93,7 @@ class DowntimeDetail extends BaseHtmlElement
$submitButton = $cancelDowntimeForm->getElement('btn_submit');
$submitButton->content = (new HtmlDocument())
->add([new Icon('trash'), 'Cancel Downtime'])
->add([new Icon('trash'), t('Cancel Downtime')])
->setSeparator(' ')
->render();
@ -107,47 +107,51 @@ class DowntimeDetail extends BaseHtmlElement
protected function assemble()
{
$this->add(Html::tag('h2', 'Comment'));
$this->add(Html::tag('h2', t('Comment')));
$this->add(Html::tag('div', [
new Icon('user'),
$this->downtime->author,
' commented:',
new MarkdownText($this->downtime->comment)
Html::sprintf(
t('%s commented: %s', '<username> ..: <comment>'),
$this->downtime->author,
new MarkdownText($this->downtime->comment)
)
]));
$this->add(Html::tag('h2', 'Details'));
$this->add(
new HorizontalKeyValue('Created', WebDateFormatter::formatDateTime($this->downtime->entry_time))
);
$this->add(
new HorizontalKeyValue('Start time', WebDateFormatter::formatDateTime($this->downtime->start_time))
);
$this->add(Html::tag('h2', t('Details')));
$this->add(new HorizontalKeyValue(
'End time',
t('Created'),
WebDateFormatter::formatDateTime($this->downtime->entry_time)
));
$this->add(new HorizontalKeyValue(
t('Start time'),
WebDateFormatter::formatDateTime($this->downtime->start_time)
));
$this->add(new HorizontalKeyValue(
t('End time'),
WebDateFormatter::formatDateTime($this->downtime->end_time)
));
$this->add(new HorizontalKeyValue(
'Scheduled Start',
t('Scheduled Start'),
WebDateFormatter::formatDateTime($this->downtime->scheduled_start_time)
));
$this->add(new HorizontalKeyValue(
'Scheduled End',
t('Scheduled End'),
WebDateFormatter::formatDateTime($this->downtime->scheduled_end_time)
));
$this->add(new HorizontalKeyValue(
'Scheduled Duration',
t('Scheduled Duration'),
DateFormatter::formatDuration(
$this->downtime->scheduled_end_time - $this->downtime->scheduled_start_time
)
));
if ($this->downtime->is_flexible) {
$this->add(new HorizontalKeyValue(
'Flexible Duration',
t('Flexible Duration'),
DateFormatter::formatDuration($this->downtime->flexible_duration)
));
}
$this->add(Html::tag('h2', 'Progress'));
$this->add(Html::tag('h2', t('Progress')));
$this->add($this->createTimeline());
if ($this->getAuth()->hasPermission('monitoring/command/downtime/delete')) {

View file

@ -26,11 +26,11 @@ class HostDetail extends ObjectDetail
$services = new ServiceStatistics($this->serviceSummary);
$services->setBaseFilter(Filter::where('host.name', $this->object->name));
} else {
$services = new EmptyState(mt('icingadb', 'This host has no services'));
$services = new EmptyState(t('This host has no services'));
}
$stats = [Html::tag('h2', mt('icingadb', 'Services'))];
$stats[] = new HorizontalKeyValue(mt('icingadb', 'Services'), $services);
$stats = [Html::tag('h2', t('Services'))];
$stats[] = new HorizontalKeyValue(t('Services'), $services);
return $stats;
}

View file

@ -40,7 +40,7 @@ class HostStatistics extends ObjectStatistics
return new Link(
new VerticalKeyValue(
mtp('icingadb', 'Host', 'Hosts', $this->summary->hosts_total),
tp('Host', 'Hosts', $this->summary->hosts_total),
$this->summary->hosts_total
),
$url

View file

@ -44,9 +44,9 @@ class MultiselectQuickActions extends BaseHtmlElement
) {
$this->assembleAction(
'acknowledge',
'Acknowledge',
t('Acknowledge'),
'icon-edit',
'Acknowledge this problem, suppress all future notifications for it and tag it as being handled'
t('Acknowledge this problem, suppress all future notifications for it and tag it as being handled')
);
}
@ -78,27 +78,27 @@ class MultiselectQuickActions extends BaseHtmlElement
if ($this->getAuth()->hasPermission('monitoring/command/comment/add')) {
$this->assembleAction(
'addComment',
'Comment',
t('Comment'),
'icon-comment-empty',
'Add a new comment'
t('Add a new comment')
);
}
if ($this->getAuth()->hasPermission('monitoring/command/send-custom-notification')) {
$this->assembleAction(
'sendCustomNotification',
'Notification',
t('Notification'),
'icon-bell',
'Send a custom notification'
t('Send a custom notification')
);
}
if ($this->getAuth()->hasPermission('monitoring/command/downtime/schedule')) {
$this->assembleAction(
'scheduleDowntime',
'Downtime',
t('Downtime'),
'icon-plug',
'Schedule a downtime to suppress all problem notifications within a specific period of time'
t('Schedule a downtime to suppress all problem notifications within a specific period of time')
);
}
@ -111,18 +111,18 @@ class MultiselectQuickActions extends BaseHtmlElement
) {
$this->assembleAction(
'scheduleCheck',
'Reschedule',
t('Reschedule'),
'icon-calendar-empty',
'Schedule the next active check at a different time than the current one'
t('Schedule the next active check at a different time than the current one')
);
}
if ($this->getAuth()->hasPermission('monitoring/command/process-check-result')) {
$this->assembleAction(
'processCheckresult',
'Process check result',
t('Process check result'),
'icon-edit',
'Submit passive check result'
t('Submit passive check result')
);
}
}

View file

@ -68,7 +68,7 @@ class ObjectDetail extends BaseHtmlElement
foreach ($this->compatObject->getActionUrls() as $i => $url) {
$navigation->addItem(
'Action ' . ($i + 1),
sprintf(t('Action %d'), $i + 1),
[
'renderer' => [
'NavigationItemRenderer',
@ -90,7 +90,7 @@ class ObjectDetail extends BaseHtmlElement
}
return [
Html::tag('h2', 'Actions'),
Html::tag('h2', t('Actions')),
new HtmlString($navigation->getRenderer()->setCssClass('actions')->render())
];
}
@ -98,7 +98,7 @@ class ObjectDetail extends BaseHtmlElement
protected function createCheckStatistics()
{
return [
Html::tag('h2', 'Check Statistics'),
Html::tag('h2', t('Check Statistics')),
new CheckStatistics($this->object)
];
}
@ -116,13 +116,13 @@ class ObjectDetail extends BaseHtmlElement
/** @var ResultSet $comments */
$comments = $this->object->comment->with($relations)->limit(3)->peekAhead()->execute();
$content = [Html::tag('h2', 'Comments')];
$content = [Html::tag('h2', t('Comments'))];
if ($comments->hasResult()) {
$content[] = new CommentList($comments);
$content[] = new ShowMore($comments, $link);
} else {
$content[] = new EmptyState('No comments created.');
$content[] = new EmptyState(t('No comments created.'));
}
return $content;
@ -130,7 +130,7 @@ class ObjectDetail extends BaseHtmlElement
protected function createCustomVars()
{
$content = [Html::tag('h2', 'Custom Variables')];
$content = [Html::tag('h2', t('Custom Variables'))];
$vars = $this->object->customvar->execute();
if ($vars->hasResult()) {
@ -143,7 +143,7 @@ class ObjectDetail extends BaseHtmlElement
$content[] = new CustomVarTable($vars);
} else {
$content[] = new EmptyState('No custom variables configured.');
$content[] = new EmptyState(t('No custom variables configured.'));
}
return $content;
@ -159,13 +159,13 @@ class ObjectDetail extends BaseHtmlElement
$downtimes = $this->object->downtime->limit(3)->peekAhead()->execute();
$content = [Html::tag('h2', 'Downtimes')];
$content = [Html::tag('h2', t('Downtimes'))];
if ($downtimes->hasResult()) {
$content[] = new DowntimeList($downtimes);
$content[] = new ShowMore($downtimes, $link);
} else {
$content[] = new EmptyState('No downtimes scheduled.');
$content[] = new EmptyState(t('No downtimes scheduled.'));
}
return $content;
@ -177,7 +177,7 @@ class ObjectDetail extends BaseHtmlElement
protected function createGroups()
{
$groups = [Html::tag('h2', 'Groups')];
$groups = [Html::tag('h2', t('Groups'))];
if ($this->objectType === 'host') {
$hostgroupList = new TagList();
@ -187,10 +187,10 @@ class ObjectDetail extends BaseHtmlElement
}
$groups[] = new HorizontalKeyValue(
'Host Groups',
t('Host Groups'),
$hostgroupList->hasContent()
? $hostgroupList
: new EmptyState('Not a member of any host group.')
: new EmptyState(t('Not a member of any host group.'))
);
} else {
$servicegroupList = new TagList();
@ -200,10 +200,10 @@ class ObjectDetail extends BaseHtmlElement
}
$groups[] = new HorizontalKeyValue(
'Service Groups',
t('Service Groups'),
$servicegroupList->hasContent()
? $servicegroupList
: new EmptyState('Not a member of any service group.')
: new EmptyState(t('Not a member of any service group.'))
);
}
@ -217,7 +217,7 @@ class ObjectDetail extends BaseHtmlElement
foreach ($this->compatObject->getNotesUrls() as $i => $url) {
$navigation->addItem(
'Notes ' . ($i + 1),
sprintf(t('Note %d'), $i + 1),
[
'renderer' => 'NavigationItemRenderer',
'target' => '_blank',
@ -245,7 +245,7 @@ class ObjectDetail extends BaseHtmlElement
return null;
}
array_unshift($content, Html::tag('h2', 'Notes'));
array_unshift($content, Html::tag('h2', t('Notes')));
return $content;
}
@ -269,14 +269,16 @@ class ObjectDetail extends BaseHtmlElement
}
return [
Html::tag('h2', 'Notifications'),
Html::tag('h2', t('Notifications')),
new HorizontalKeyValue(
'Users',
$userList->hasContent() ? $userList : new EmptyState('No users configured.')
t('Users'),
$userList->hasContent() ? $userList : new EmptyState(t('No users configured.'))
),
new HorizontalKeyValue(
'User Groups',
$usergroupList->hasContent() ? $usergroupList : new EmptyState('No user groups configured.')
t('User Groups'),
$usergroupList->hasContent()
? $usergroupList
: new EmptyState(t('No user groups configured.'))
)
];
}
@ -289,10 +291,10 @@ class ObjectDetail extends BaseHtmlElement
$helper = new Zend_View_Helper_Perfdata();
$helper->view = Icinga::app()->getViewRenderer()->view;
$content[] = Html::tag('h2', 'Performance Data');
$content[] = Html::tag('h2', t('Performance Data'));
if (empty($this->object->state->performance_data)) {
$content[] = new EmptyState('No performance data available.');
$content[] = new EmptyState(t('No performance data available.'));
} else {
$content[] = new HtmlString($helper->perfdata($this->object->state->performance_data));
}
@ -303,7 +305,7 @@ class ObjectDetail extends BaseHtmlElement
protected function createPluginOutput()
{
return [
Html::tag('h2', 'Plugin Output'),
Html::tag('h2', t('Plugin Output')),
Html::tag(
'div',
['class' => 'collapsible'],
@ -329,7 +331,7 @@ class ObjectDetail extends BaseHtmlElement
}
return [
Html::tag('h2', 'Feature Commands'),
Html::tag('h2', t('Feature Commands')),
HtmlString::create($form->render())
];
}

View file

@ -53,7 +53,10 @@ class ObjectsDetail extends BaseHtmlElement
$content->add([
HtmlString::create($hostsChart->render()),
new VerticalKeyValue('Hosts', $this->summary->hosts_total),
new VerticalKeyValue(
tp('Host', 'Hosts', $this->summary->hosts_total),
$this->summary->hosts_total
),
new HostStateBadges($badges)
]);
} else {
@ -72,7 +75,10 @@ class ObjectsDetail extends BaseHtmlElement
$content->add([
HtmlString::create($servicesChart->render()),
new VerticalKeyValue('Services', $this->summary->services_total),
new VerticalKeyValue(
tp('Service', 'Services', $this->summary->services_total),
$this->summary->services_total
),
$badges
]);
}
@ -82,15 +88,18 @@ class ObjectsDetail extends BaseHtmlElement
protected function createComments()
{
$content = [Html::tag('h2', 'Comments')];
$content = [Html::tag('h2', t('Comments'))];
if ($this->summary->comments_total > 0) {
$content[] = new ActionLink(
sprintf('Show %d comments', $this->summary->comments_total),
sprintf(
tp('Show %d comment', 'Show %d comments', $this->summary->comments_total),
$this->summary->comments_total
),
Links::comments()->setQueryString($this->getBaseFilter()->toQueryString())
);
} else {
$content[] = new EmptyState('No comments created.');
$content[] = new EmptyState(t('No comments created.'));
}
return $content;
@ -98,15 +107,18 @@ class ObjectsDetail extends BaseHtmlElement
protected function createDowntimes()
{
$content = [Html::tag('h2', 'Downtimes')];
$content = [Html::tag('h2', t('Downtimes'))];
if ($this->summary->downtimes_total > 0) {
$content[] = new ActionLink(
sprintf('Show %d downtimes', $this->summary->downtimes_total),
sprintf(
tp('Show %d downtime', 'Show %d downtimes', $this->summary->downtimes_total),
$this->summary->downtimes_total
),
Links::downtimes()->setQueryString($this->getBaseFilter()->toQueryString())
);
} else {
$content[] = new EmptyState('No downtimes scheduled.');
$content[] = new EmptyState(t('No downtimes scheduled.'));
}
return $content;
@ -127,7 +139,7 @@ class ObjectsDetail extends BaseHtmlElement
}
return [
Html::tag('h2', 'Feature Commands'),
Html::tag('h2', t('Feature Commands')),
HtmlString::create($form->render())
];
}
@ -135,7 +147,7 @@ class ObjectsDetail extends BaseHtmlElement
protected function createSummary()
{
return [
Html::tag('h2', 'Summary'),
Html::tag('h2', t('Summary')),
$this->createChart()
];
}

View file

@ -46,9 +46,9 @@ class QuickActions extends BaseHtmlElement
} elseif ($this->getAuth()->hasPermission('monitoring/command/acknowledge-problem')) {
$this->assembleAction(
'acknowledge',
'Acknowledge',
t('Acknowledge'),
'icon-edit',
'Acknowledge this problem, suppress all future notifications for it and tag it as being handled'
t('Acknowledge this problem, suppress all future notifications for it and tag it as being handled')
);
}
}
@ -69,27 +69,27 @@ class QuickActions extends BaseHtmlElement
if ($this->getAuth()->hasPermission('monitoring/command/comment/add')) {
$this->assembleAction(
'addComment',
'Comment',
t('Comment', 'verb'),
'icon-comment-empty',
'Add a new comment'
t('Add a new comment')
);
}
if ($this->getAuth()->hasPermission('monitoring/command/send-custom-notification')) {
$this->assembleAction(
'sendCustomNotification',
'Notification',
t('Notification'),
'icon-bell',
'Send a custom notification'
t('Send a custom notification')
);
}
if ($this->getAuth()->hasPermission('monitoring/command/downtime/schedule')) {
$this->assembleAction(
'scheduleDowntime',
'Downtime',
t('Downtime'),
'icon-plug',
'Schedule a downtime to suppress all problem notifications within a specific period of time'
t('Schedule a downtime to suppress all problem notifications within a specific period of time')
);
}
@ -102,18 +102,21 @@ class QuickActions extends BaseHtmlElement
) {
$this->assembleAction(
'scheduleCheck',
'Reschedule',
t('Reschedule'),
'icon-calendar-empty',
'Schedule the next active check at a different time than the current one'
t('Schedule the next active check at a different time than the current one')
);
}
if ($this->getAuth()->hasPermission('monitoring/command/process-check-result')) {
$this->assembleAction(
'processCheckresult',
'Process check result',
t('Process check result'),
'icon-edit',
sprintf('Submit a one time or so called passive result for the %s check', $this->object->checkcommand)
sprintf(
t('Submit a one time or so called passive result for the %s check'),
$this->object->checkcommand
)
);
}
}

View file

@ -44,7 +44,7 @@ class ServiceStatistics extends ObjectStatistics
return new Link(
new VerticalKeyValue(
mtp('icingadb', 'Service', 'Services', $this->summary->services_total),
tp('Service', 'Services', $this->summary->services_total),
$this->summary->services_total
),
$url

View file

@ -22,34 +22,40 @@ class Health extends BaseHtmlElement
{
if ($this->data->heartbeat > time() - 60) {
$this->add(Html::tag('div', ['class' => 'icinga-health up'], [
'Icinga 2 is up and running ', new TimeSince($this->data->icinga2_start_time)
Html::sprintf(
t('Icinga 2 is up and running %s', '...since <timespan>'),
new TimeSince($this->data->icinga2_start_time)
)
]));
} else {
$this->add(Html::tag('div', ['class' => 'icinga-health down'], [
'Icinga 2 or Icinga DB is not running ', new TimeSince($this->data->heartbeat)
Html::sprintf(
t('Icinga 2 or Icinga DB is not running %s', '...since <timespan>'),
new TimeSince($this->data->heartbeat)
)
]));
}
$icingaInfo = Html::tag('div', ['class' => 'icinga-info'], [
new VerticalKeyValue(
'Icinga 2 Version',
t('Icinga 2 Version'),
$this->data->icinga2_version
),
new VerticalKeyValue(
'Icinga 2 Start Time',
t('Icinga 2 Start Time'),
new TimeAgo($this->data->icinga2_start_time)
),
new VerticalKeyValue(
'Last Heartbeat',
t('Last Heartbeat'),
new TimeAgo($this->data->heartbeat)
),
new VerticalKeyValue(
'Active Icinga 2 Endpoint',
$this->data->endpoint->name ?: 'N/A'
t('Active Icinga 2 Endpoint'),
$this->data->endpoint->name ?: t('N/A')
),
new VerticalKeyValue(
'Active Icinga Web Endpoint',
gethostname() ?: 'N/A'
t('Active Icinga Web Endpoint'),
gethostname() ?: t('N/A')
)
]);
$this->add($icingaInfo);

View file

@ -11,7 +11,7 @@ class HostStatusBar extends BaseStatusBar
{
protected function assembleTotal(BaseHtmlElement $total)
{
$total->add(sprintf('%d Hosts', $this->summary->hosts_total));
$total->add(sprintf(tp('%d Host', '%d Hosts', $this->summary->hosts_total), $this->summary->hosts_total));
}
protected function createStateBadges()

View file

@ -42,7 +42,7 @@ class HostSummaryDonut extends Card
'sort' => 'host.state.last_state_change'
]))
->setLabelBigEyeCatching($this->summary->hosts_down_unhandled > 0)
->setLabelSmall(mt('icingadb', 'Hosts Down'));
->setLabelSmall(tp('Host Down', 'Hosts Down', $this->summary->hosts_down_unhandled));
$body->add(new HtmlElement('div', ['class' => 'donut'], new HtmlString($donut->render())));
}
@ -54,6 +54,6 @@ class HostSummaryDonut extends Card
protected function assembleHeader(BaseHtmlElement $header)
{
$header->add(new HtmlElement('h2', null, mt('icingadb', 'Host Summary')));
$header->add(new HtmlElement('h2', null, t('Host Summary')));
}
}

View file

@ -36,11 +36,10 @@ abstract class BaseCommentListItem extends BaseListItem
$header->add([
new Icon(Icons::USER),
new Link(
[
$this->item->author,
' ',
($isAck ? 'acknowledged' : 'commented')
],
sprintf(
$isAck ? t('%s acknowledged', '<username>..') : t('%s commented', '<username>..'),
$this->item->author
),
Links::comment($this->item)
)
]);
@ -56,7 +55,7 @@ abstract class BaseCommentListItem extends BaseListItem
}
if ($expires != 0) {
$header->add(HTML::tag('span', ['class' => 'ack-badge badge'], 'EXPIRES'));
$header->add(HTML::tag('span', ['class' => 'ack-badge badge'], t('EXPIRES')));
}
$header->add(Html::tag('br'));

View file

@ -102,12 +102,6 @@ abstract class BaseDowntimeListItem extends BaseListItem
protected function assembleTitle(BaseHtmlElement $title)
{
if ($this->item->is_flexible) {
$type = 'Flexible';
} else {
$type = 'Fixed';
}
if ($this->item->object_type === 'host') {
$link = $this->createHostLink($this->item->host, true);
} else {
@ -115,7 +109,12 @@ abstract class BaseDowntimeListItem extends BaseListItem
}
$title->add([
new Link("{$type} Downtime", Links::downtime($this->item)),
new Link(
$this->item->is_flexible
? t('Flexible Downtime')
: t('Fixed Downtime'),
Links::downtime($this->item)
),
': ',
$link
]);
@ -129,7 +128,9 @@ abstract class BaseDowntimeListItem extends BaseListItem
if ($this->item->is_in_effect) {
$visual->addAttributes(['class' => 'active']);
}
$visual->add([
$visual->add(Html::sprintf(
t('%s left', '<timespan>..'),
Html::tag(
'strong',
Html::tag(
@ -140,10 +141,8 @@ abstract class BaseDowntimeListItem extends BaseListItem
],
DateFormatter::formatDuration($this->duration, true)
)
),
' ',
'left'
]);
)
));
} else {
$visual->add([
'in',

View file

@ -51,23 +51,25 @@ class HistoryListItem extends CommonListItem
break;
case 'flapping_start':
$caption
->add(
'State Change Rate: ' . $this->item->flapping->percent_state_change_start
. '%; Start Threshold: ' . $this->item->host->flapping_threshold_high . '%'
)
->add(sprintf(
t('State Change Rate: %.2f%%; Start Threshold: %.2f%%'),
$this->item->flapping->percent_state_change_start,
$this->item->host->flapping_threshold_high
))
->getAttributes()
->add('class', 'plugin-output');
break;
case 'flapping_end':
$caption
->add(
'State Change Rate: ' . $this->item->host->flapping_threshold_low
. '%; End Threshold: ' . $this->item->host->flapping_threshold_high
. '%; Flapping for ' . DateFormatter::formatDuration(
->add(sprintf(
t('State Change Rate: %.2f%%; End Threshold: %.2f%%; Flapping for %s'),
$this->item->host->flapping_threshold_low,
$this->item->host->flapping_threshold_high,
DateFormatter::formatDuration(
$this->item->flapping->end_time - $this->item->flapping->start_time
)
)
))
->getAttributes()
->add('class', 'plugin-output');
@ -76,8 +78,10 @@ class HistoryListItem extends CommonListItem
if (! empty($this->item->acknowledgement->cleared_by)) {
$caption->add([
new Icon(Icons::USER),
'Cleared by: ',
$this->item->acknowledgement->cleared_by
sprintf(
t('Cleared by: %s', '..<username>'),
$this->item->acknowledgement->cleared_by
)
]);
break;
@ -184,40 +188,40 @@ class HistoryListItem extends CommonListItem
{
switch ($this->item->event_type) {
case 'comment_add':
$title->add('Comment added');
$title->add(t('Comment added'));
break;
case 'comment_remove':
$title->add('Comment removed');
$title->add(t('Comment removed'));
break;
case 'downtime_end':
$title->add('Downtime ended');
$title->add(t('Downtime ended'));
break;
case 'downtime_start':
$title->add('Downtime started');
$title->add(t('Downtime started'));
break;
case 'flapping_start':
$title->add('Flapping started');
$title->add(t('Flapping started'));
break;
case 'flapping_end':
$title->add('Flapping ended');
$title->add(t('Flapping ended'));
break;
case 'ack_set':
$title->add('Acknowledgement set');
$title->add(t('Acknowledgement set'));
break;
case 'ack_clear':
$title->add('Acknowledgement cleared');
$title->add(t('Acknowledgement cleared'));
break;
case 'notification':
$title->add([
'Notification',
t('Notification'),
': ',
sprintf(
NotificationListItem::PHRASES[$this->item->notification->type],
@ -227,7 +231,11 @@ class HistoryListItem extends CommonListItem
break;
case 'state_change':
$title->add(sprintf('%s state changed', ucfirst($this->item->state->state_type)));
if ($this->item->state->state_type === 'hard') {
$title->add(t('Hard state changed'));
} else {
$title->add(t('Soft state changed'));
}
break;
default:

View file

@ -29,7 +29,7 @@ class PageSeparatorItem extends BaseHtmlElement
[
'id' => 'page-' . $this->pageNumber
],
'Page ' . $this->pageNumber
sprintf(t('Page %d'), $this->pageNumber)
));
}
}

View file

@ -11,7 +11,10 @@ class ServiceStatusBar extends BaseStatusBar
{
protected function assembleTotal(BaseHtmlElement $total)
{
$total->add(sprintf('%d Services', $this->summary->services_total));
$total->add(sprintf(
tp('%d Service', '%d Services', $this->summary->services_total),
$this->summary->services_total
));
}
protected function createStateBadges()

View file

@ -44,7 +44,9 @@ class ServiceSummaryDonut extends Card
'sort' => 'service.state.last_state_change'
]))
->setLabelBigEyeCatching($this->summary->services_critical_unhandled > 0)
->setLabelSmall(mt('icingadb', 'Services Critical'));
->setLabelSmall(
tp('Service Critical', 'Services Critical', $this->summary->services_critical_unhandled)
);
$body->add(new HtmlElement('div', ['class' => 'donut'], new HtmlString($donut->render())));
}
@ -56,6 +58,6 @@ class ServiceSummaryDonut extends Card
protected function assembleHeader(BaseHtmlElement $header)
{
$header->add(new HtmlElement('h2', null, mt('icingadb', 'Service Summary')));
$header->add(new HtmlElement('h2', null, t('Service Summary')));
}
}

View file

@ -37,7 +37,7 @@ class ShowMore extends BaseHtmlElement
public function getLabel()
{
return $this->label ?: 'Show More';
return $this->label ?: t('Show More');
}
protected function assemble()

View file

@ -33,7 +33,7 @@ abstract class StateListItem extends BaseListItem
protected function assembleCaption(BaseHtmlElement $caption)
{
if ($this->state->soft_state === null && $this->state->output === null) {
$caption->add(Text::create(mt('icingadb', 'Waiting for Icinga DB to synchronize the state.')));
$caption->add(Text::create(t('Waiting for Icinga DB to synchronize the state.')));
} else {
$caption->add(CompatPluginOutput::getInstance()->render($this->state->output));
}
@ -41,11 +41,11 @@ abstract class StateListItem extends BaseListItem
protected function assembleTitle(BaseHtmlElement $title)
{
$title->add([
$title->add(Html::sprintf(
t('%s is %s', '<hostname> is <state-text>'),
$this->createSubject(),
' is ',
Html::tag('span', ['class' => 'state-text'], $this->state->getStateTextTranslated())
]);
));
}
protected function assembleVisual(BaseHtmlElement $visual)
@ -81,7 +81,7 @@ abstract class StateListItem extends BaseListItem
{
if ($this->state->is_overdue) {
$since = new TimeSince($this->state->next_update);
$since->prepend('Overdue ');
$since->prepend(t('Overdue') . ' ');
$since->prepend(new Icon(Icons::WARNING));
return $since;
} elseif ($this->state->last_state_change !== null) {