chg: [i18n] Made the strings more i18n friendly across the application

pull/3368/head
iglocska 2018-06-20 12:56:53 +02:00
parent c470f1a36e
commit 214df94bda
13 changed files with 43 additions and 41 deletions

View File

@ -733,15 +733,17 @@ class AttributesController extends AppController {
$this->Event->saveField('published', 0);
// everything is done, now redirect to event view
$message = 'The ThreatConnect data has been imported.';
$message = __('The ThreatConnect data has been imported.');
if ($results['successes'] != 0) {
$flashType = 'success';
$message .= ' ' . $results['successes'] . ' entries imported.';
$temp = sprintf(__('%s entries imported.'), $results['successes']);
$message .= ' ' . $temp;
}
if ($results['fails'] != 0) {
$message .= ' ' . $results['fails'] . ' entries could not be imported.';
$temp = sprintf(__('%s entries could not be imported.'), $results['fails']);
$message .= ' ' . $temp;
}
$this->Flash->{empty($flashType) ? 'error' : $flashType}(__($message));
$this->Flash->{empty($flashType) ? 'error' : $flashType}($message);
$this->redirect(array('controller' => 'events', 'action' => 'view', $this->request->data['Attribute']['event_id']));
} else {

View File

@ -15,11 +15,11 @@ class AdminCrudComponent extends AuthComponent {
if ($this->controller->request->is('post')) {
$this->controller->{$this->controller->defaultModel}->create();
if ($this->controller->{$this->controller->defaultModel}->save($this->controller->request->data)) {
$this->controller->Session->setFlash(__(sprintf('The %s has been saved.', strtolower($this->controller->defaultModel))));
$this->controller->Session->setFlash(sprintf(__('The %s has been saved.'), strtolower($this->controller->defaultModel)));
$this->controller->redirect(array('action' => 'index'));
} else {
if (!($this->Session->check('Message.flash'))) {
$this->controller->Session->setFlash(__(sprintf('The %s could not be saved. Please, try again.', strtolower($this->controller->defaultModel))));
$this->controller->Session->setFlash(sprintf(__('The %s could not be saved. Please, try again.'), strtolower($this->controller->defaultModel)));
}
}
}
@ -45,16 +45,16 @@ class AdminCrudComponent extends AuthComponent {
public function adminEdit($id = null) {
$this->controller->{$this->controller->defaultModel}->id = $id;
if (!$this->controller->{$this->controller->defaultModel}->exists()) {
throw new NotFoundException(__(sprintf('Invalid %s', strtolower($this->controller->defaultModel))));
throw new NotFoundException(sprintf(__('Invalid %s'), strtolower($this->controller->defaultModel)));
}
if ($this->controller->request->is('post') || $this->controller->request->is('put')) {
$this->controller->request->data[$this->controller->defaultModel]['id'] = $id;
if ($this->controller->{$this->controller->defaultModel}->save($this->controller->request->data)) {
$this->controller->Session->setFlash(__(sprintf('The %s has been saved', strtolower($this->controller->defaultModel))));
$this->controller->Session->setFlash(sprintf(__('The %s has been saved'), strtolower($this->controller->defaultModel)));
$this->controller->redirect(array('action' => 'index'));
} else {
if (!($this->Session->check('Message.flash'))) {
$this->controller->Session->setFlash(__(sprintf('The %s could not be saved. Please, try again.', strtolower($this->controller->defaultModel))));
$this->controller->Session->setFlash(sprintf(__('The %s could not be saved. Please, try again.'), strtolower($this->controller->defaultModel)));
}
}
} else {
@ -77,13 +77,13 @@ class AdminCrudComponent extends AuthComponent {
}
$this->controller->{$this->controller->defaultModel}->id = $id;
if (!$this->controller->{$this->controller->defaultModel}->exists()) {
throw new NotFoundException(__(sprintf('Invalid %s', strtolower($this->controller->defaultModel))));
throw new NotFoundException(sprintf(__('Invalid %s'), strtolower($this->controller->defaultModel)));
}
if ($this->controller->{$this->controller->defaultModel}->delete()) {
$this->controller->Session->setFlash(__(sprintf('%s deleted', $this->controller->defaultModel)));
$this->controller->Session->setFlash(sprintf(__('%s deleted'), $this->controller->defaultModel));
$this->controller->redirect(array('action' => 'index'));
}
$this->controller->Session->setFlash(__(sprintf('%s was not deleted', $this->controller->defaultModel)));
$this->controller->Session->setFlash(sprintf(__('%s was not deleted'), $this->controller->defaultModel));
$this->controller->redirect(array('action' => 'index'));
}

View File

@ -59,13 +59,13 @@ class BlackListComponent extends Component {
$fails[] = $uuid;
}
}
$message = 'Done. Added ' . count($successes) . ' new entries to the blacklist. ' . count($fails) . ' entries could not be saved.';
$message = sprintf(__('Done. Added %d new entries to the blacklist. %d entries could not be saved.'), count($successes), count($fails));
if ($rest) {
$this->set('result', array('successes' => $successes, 'fails' => $fails));
$this->set('message', $message);
$this->set('_serialize', array('message', 'result'));
} else {
$this->controller->Session->setFlash(__($message));
$this->controller->Session->setFlash($message);
$this->controller->redirect(array('action' => 'index'));
}
}

View File

@ -60,7 +60,7 @@ class RolesController extends AppController {
return $this->RestResponse->saveFailResponse('Role', 'admin_add', false, $this->Role->validationErrors, $this->response->type());
} else {
if (!($this->Session->check('Message.flash'))) {
$this->Role->Session->setFlash(__(sprintf('The Role could not be saved. Please, try again.')));
$this->Role->Session->setFlash(__('The Role could not be saved. Please, try again.'));
}
}
}
@ -98,7 +98,7 @@ class RolesController extends AppController {
return $this->RestResponse->saveFailResponse('Role', 'admin_edit', false, $this->Role->validationErrors, $this->response->type());
} else {
if (!($this->Session->check('Message.flash'))) {
$this->Role->Session->setFlash(__(sprintf('The Role could not be saved. Please, try again.')));
$this->Role->Session->setFlash(__('The Role could not be saved. Please, try again.'));
}
}
}

View File

@ -1202,7 +1202,7 @@ class ServersController extends AppController {
// only keep the last part of the filename, this should prevent directory attacks
$filename = basename($this->request->data['Server']['file']['name']);
if (!preg_match("/" . $validItems[$type]['regex'] . "/", $filename)) {
$this->Flash->error(__($validItems[$type]['regex_error'], true), 'default', array(), 'error');
$this->Flash->error($validItems[$type]['regex_error'], 'default', array(), 'error');
$this->redirect(array('controller' => 'servers', 'action' => 'serverSettings', 'files'));
}
if (empty($this->request->data['Server']['file']['tmp_name']) || !is_uploaded_file($this->request->data['Server']['file']['tmp_name'])) {

View File

@ -2813,28 +2813,28 @@ class Server extends AppModel {
public function getFileRules() {
$validItems = array(
'orgs' => array(
'name' => 'Organisation logos',
'description' => 'The logo used by an organisation on the event index, event view, discussions, proposals, etc. Make sure that the filename is in the org.png format, where org is the case-sensitive organisation name.',
'name' => __('Organisation logos'),
'description' => __('The logo used by an organisation on the event index, event view, discussions, proposals, etc. Make sure that the filename is in the org.png format, where org is the case-sensitive organisation name.'),
'expected' => array(),
'valid_format' => '48x48 pixel .png files',
'valid_format' => __('48x48 pixel .png files'),
'path' => APP . 'webroot' . DS . 'img' . DS . 'orgs',
'regex' => '.*\.(png|PNG)$',
'regex_error' => 'Filename must be in the following format: *.png',
'regex_error' => __('Filename must be in the following format: *.png'),
'files' => array(),
),
'img' => array(
'name' => 'Additional image files',
'description' => 'Image files uploaded into this directory can be used for various purposes, such as for the login page logos',
'name' => __('Additional image files'),
'description' => __('Image files uploaded into this directory can be used for various purposes, such as for the login page logos'),
'expected' => array(
'MISP.footer_logo' => Configure::read('MISP.footer_logo'),
'MISP.home_logo' => Configure::read('MISP.home_logo'),
'MISP.welcome_logo' => Configure::read('MISP.welcome_logo'),
'MISP.welcome_logo2' => Configure::read('MISP.welcome_logo2'),
),
'valid_format' => 'text/html if served inline, anything that conveys the terms of use if served as download',
'valid_format' => __('text/html if served inline, anything that conveys the terms of use if served as download'),
'path' => APP . 'webroot' . DS . 'img' . DS . 'custom',
'regex' => '.*\.(png|PNG)$',
'regex_error' => 'Filename must be in the following format: *.png',
'regex_error' => __('Filename must be in the following format: *.png'),
'files' => array(),
),
);

View File

@ -121,7 +121,7 @@
);
echo sprintf(
'<span class="icon-trash icon-white useCursorPointer" title="%1$s" role="button" tabindex="0" aria-label="%1$s" onClick="%2$s"></span>',
__((empty($event['Event']['publish_timestamp']) ? 'Permanently' : 'Soft') . ' delete object'),
(empty($event['Event']['publish_timestamp']) ? __('Permanently delete object') : __('Soft delete object')),
sprintf(
'deleteObject(\'objects\', \'delete\', \'%s\', \'%s\');',
empty($event['Event']['publish_timestamp']) ? h($object['id']) . '/true' : h($object['id']),

View File

@ -4,14 +4,13 @@
<div class="templateTableRow ui-sortable-handle">
<div class="templateElementHeader" style="width:100%; position:relative;">
<div class="templateGlass"></div>
<div class="templateElementHeaderText"><?php echo h(__($type)); ?></div>
<div class="templateElementHeaderText"><?php echo h($type); ?></div>
</div>
<div style="padding:10px;">
<div><?php echo h(__($moduleTypes[$type]['description'])); ?></div>
<div><?php echo h($moduleTypes[$type]['description']); ?></div>
<div><span class="bold"><?php echo __('Status'); ?></span>: <span id="<?php echo h(strtolower($type)); ?>_type">&nbsp;</span></div>
<?php
foreach ($branches as $branch):
debug($modules[$type][$branch]);
if (isset($modules[$type][$branch])):
if (isset($modules[$type][$branch]['value'])) {
$modules[$type][$branch] = array($branch => $modules[$type][$branch]);
@ -33,8 +32,6 @@
if ($moduleSettings['enabled']['value']) $enabledModuleCounter++;
endforeach;
endif;
debug($moduleCounter);
debug($enabledModuleCounter);
?>
</div>
</div>

View File

@ -485,10 +485,10 @@
<b>searchDateuntil</b>: <?php echo __('Filters on the date, anything older than the given date in YYYY-MM-DD format is taken - non-negatable');?><br /></p>
<?php
foreach ($command_line_functions as $clusterRef => $cluster) {
echo sprintf('<a id="%s"></a><h3>%s</h3>', $clusterRef, __($cluster['header']));
echo sprintf('<p>%s:<br />', __($cluster['description']));
echo sprintf('<a id="%s"></a><h3>%s</h3>', $clusterRef, $cluster['header']);
echo sprintf('<p>%s:<br />', $cluster['description']);
foreach ($cluster['data'] as $commandName => $command) {
echo '<b>' . __(Inflector::humanize($commandName)) . '</b>: <code>' . $command . '</code><br />';
echo '<b>' . Inflector::humanize($commandName) . '</b>: <code>' . $command . '</code><br />';
}
}
?>

View File

@ -25,7 +25,7 @@
if ($field == 'analysis') {
$data[0] = $analysisLevels[intval($data[0])];
}
echo '<span class="blue bold">' . ucfirst(__($field)) . '</span>: ' . h($data[0]) . '<br />';
echo '<span class="blue bold">' . ucfirst($field) . '</span>: ' . h($data[0]) . '<br />';
}
}
}

View File

@ -26,7 +26,7 @@
} else {
$value = h($noticelist['Noticelist'][$field_name]);
}
$fields[] = sprintf('<dt>%s</dt><dd>%s</dd>', __(Inflector::humanize($field_name)), $value);
$fields[] = sprintf('<dt>%s</dt><dd>%s</dd>', Inflector::humanize($field_name), $value);
}
$dl = implode($fields);
echo sprintf('<dl>%s</dl>', $dl);

View File

@ -11,13 +11,16 @@
<div style="padding-left:5px;padding-right:5px;padding-bottom:5px;">
<?php
$type = 'soft-';
if ($hard) $type = 'hard-';
$typeMessage = __('Are you sure you want to soft delete Object reference #%s?%s');
if ($hard) {
$type = 'hard-';
$typeMessage = __('Are you sure you want to hard delete Object reference #%s?%s');
}
?>
<p>
<?php
echo __(
'Are you sure you want to %s delete Object reference #%s?%s',
__($type),
echo sprintf(
$typeMessage,
$id,
$hard ? __(' The Attribute will be permanently deleted and unrecoverable. Also, this will prevent the deletion to be propagated to other instances.') : ''
);

View File

@ -26,7 +26,7 @@
foreach ($nameParts as &$p) $p = ucfirst($p);
$name = implode(' ', $nameParts);
?>
<dt><?php echo __($name); ?></dt>
<dt><?php echo $name; ?></dt>
<dd class="<?php echo $role['Role'][$k] ? 'green' : 'red';?>">
<?php echo $role['Role'][$k] ? 'Yes' : 'No'; ?>
&nbsp;