Replace t() and mt() with translate() in the application's forms

refs #7551
This commit is contained in:
Johannes Meyer 2015-01-19 11:26:23 +01:00
parent 8c87a9df13
commit dbd69ba693
19 changed files with 203 additions and 181 deletions

View File

@ -18,7 +18,7 @@ class LoginForm extends Form
public function init() public function init()
{ {
$this->setName('form_login'); $this->setName('form_login');
$this->setSubmitLabel(t('Login')); $this->setSubmitLabel($this->translate('Login'));
} }
/** /**
@ -31,8 +31,8 @@ class LoginForm extends Form
'username', 'username',
array( array(
'required' => true, 'required' => true,
'label' => t('Username'), 'label' => $this->translate('Username'),
'placeholder' => t('Please enter your username...'), 'placeholder' => $this->translate('Please enter your username...'),
'class' => false === isset($formData['username']) ? 'autofocus' : '' 'class' => false === isset($formData['username']) ? 'autofocus' : ''
) )
); );
@ -41,8 +41,8 @@ class LoginForm extends Form
'password', 'password',
array( array(
'required' => true, 'required' => true,
'label' => t('Password'), 'label' => $this->translate('Password'),
'placeholder' => t('...and your password'), 'placeholder' => $this->translate('...and your password'),
'class' => isset($formData['username']) ? 'autofocus' : '' 'class' => isset($formData['username']) ? 'autofocus' : ''
) )
); );

View File

@ -30,8 +30,8 @@ class AutologinBackendForm extends Form
'name', 'name',
array( array(
'required' => true, 'required' => true,
'label' => t('Backend Name'), 'label' => $this->translate('Backend Name'),
'description' => t( 'description' => $this->translate(
'The name of this authentication provider that is used to differentiate it from others' 'The name of this authentication provider that is used to differentiate it from others'
), ),
'validators' => array( 'validators' => array(
@ -52,8 +52,8 @@ class AutologinBackendForm extends Form
'text', 'text',
'strip_username_regexp', 'strip_username_regexp',
array( array(
'label' => t('Filter Pattern'), 'label' => $this->translate('Filter Pattern'),
'description' => t( 'description' => $this->translate(
'The regular expression to use to strip specific parts off from usernames.' 'The regular expression to use to strip specific parts off from usernames.'
. ' Leave empty if you do not want to strip off anything' . ' Leave empty if you do not want to strip off anything'
), ),

View File

@ -53,8 +53,8 @@ class DbBackendForm extends Form
'name', 'name',
array( array(
'required' => true, 'required' => true,
'label' => t('Backend Name'), 'label' => $this->translate('Backend Name'),
'description' => t( 'description' => $this->translate(
'The name of this authentication provider that is used to differentiate it from others' 'The name of this authentication provider that is used to differentiate it from others'
), ),
) )
@ -64,8 +64,10 @@ class DbBackendForm extends Form
'resource', 'resource',
array( array(
'required' => true, 'required' => true,
'label' => t('Database Connection'), 'label' => $this->translate('Database Connection'),
'description' => t('The database connection to use for authenticating with this provider'), 'description' => $this->translate(
'The database connection to use for authenticating with this provider'
),
'multiOptions' => false === empty($this->resources) 'multiOptions' => false === empty($this->resources)
? array_combine($this->resources, $this->resources) ? array_combine($this->resources, $this->resources)
: array() : array()
@ -107,11 +109,11 @@ class DbBackendForm extends Form
try { try {
$dbUserBackend = new DbUserBackend(ResourceFactory::createResource($form->getResourceConfig())); $dbUserBackend = new DbUserBackend(ResourceFactory::createResource($form->getResourceConfig()));
if ($dbUserBackend->count() < 1) { if ($dbUserBackend->count() < 1) {
$form->addError(t('No users found under the specified database backend')); $form->addError($this->translate('No users found under the specified database backend'));
return false; return false;
} }
} catch (Exception $e) { } catch (Exception $e) {
$form->addError(sprintf(t('Using the specified backend failed: %s'), $e->getMessage())); $form->addError(sprintf($this->translate('Using the specified backend failed: %s'), $e->getMessage()));
return false; return false;
} }

View File

@ -54,8 +54,8 @@ class LdapBackendForm extends Form
'name', 'name',
array( array(
'required' => true, 'required' => true,
'label' => t('Backend Name'), 'label' => $this->translate('Backend Name'),
'description' => t( 'description' => $this->translate(
'The name of this authentication provider that is used to differentiate it from others' 'The name of this authentication provider that is used to differentiate it from others'
) )
) )
@ -65,8 +65,8 @@ class LdapBackendForm extends Form
'resource', 'resource',
array( array(
'required' => true, 'required' => true,
'label' => t('LDAP Resource'), 'label' => $this->translate('LDAP Resource'),
'description' => t('The resource to use for authenticating with this provider'), 'description' => $this->translate('The resource to use for authenticating with this provider'),
'multiOptions' => false === empty($this->resources) 'multiOptions' => false === empty($this->resources)
? array_combine($this->resources, $this->resources) ? array_combine($this->resources, $this->resources)
: array() : array()
@ -77,8 +77,8 @@ class LdapBackendForm extends Form
'user_class', 'user_class',
array( array(
'required' => true, 'required' => true,
'label' => t('LDAP User Object Class'), 'label' => $this->translate('LDAP User Object Class'),
'description' => t('The object class used for storing users on the ldap server'), 'description' => $this->translate('The object class used for storing users on the ldap server'),
'value' => 'inetOrgPerson' 'value' => 'inetOrgPerson'
) )
); );
@ -87,8 +87,10 @@ class LdapBackendForm extends Form
'user_name_attribute', 'user_name_attribute',
array( array(
'required' => true, 'required' => true,
'label' => t('LDAP User Name Attribute'), 'label' => $this->translate('LDAP User Name Attribute'),
'description' => t('The attribute name used for storing the user name on the ldap server'), 'description' => $this->translate(
'The attribute name used for storing the user name on the ldap server'
),
'value' => 'uid' 'value' => 'uid'
) )
); );
@ -105,9 +107,11 @@ class LdapBackendForm extends Form
'base_dn', 'base_dn',
array( array(
'required' => false, 'required' => false,
'label' => t('Base DN'), 'label' => $this->translate('Base DN'),
'description' => t('The path where users can be found on the ldap server. ' . 'description' => $this->translate(
' Leave empty to select all users available on the specified resource.') 'The path where users can be found on the ldap server. Leave ' .
'empty to select all users available on the specified resource.'
)
) )
); );
return $this; return $this;
@ -146,7 +150,7 @@ class LdapBackendForm extends Form
$form->addError($e->getMessage()); $form->addError($e->getMessage());
return false; return false;
} catch (Exception $e) { } catch (Exception $e) {
$form->addError(sprintf(t('Unable to validate authentication: %s'), $e->getMessage())); $form->addError(sprintf($this->translate('Unable to validate authentication: %s'), $e->getMessage()));
return false; return false;
} }

View File

@ -31,7 +31,7 @@ class AuthenticationBackendConfigForm extends ConfigForm
public function init() public function init()
{ {
$this->setName('form_config_authbackend'); $this->setName('form_config_authbackend');
$this->setSubmitLabel(t('Save Changes')); $this->setSubmitLabel($this->translate('Save Changes'));
} }
/** /**
@ -70,7 +70,7 @@ class AuthenticationBackendConfigForm extends ConfigForm
} elseif ($type === 'autologin') { } elseif ($type === 'autologin') {
$form = new AutologinBackendForm(); $form = new AutologinBackendForm();
} else { } else {
throw new InvalidArgumentException(sprintf(t('Invalid backend type "%s" provided'), $type)); throw new InvalidArgumentException(sprintf($this->translate('Invalid backend type "%s" provided'), $type));
} }
return $form; return $form;
@ -91,9 +91,9 @@ class AuthenticationBackendConfigForm extends ConfigForm
{ {
$name = isset($values['name']) ? $values['name'] : ''; $name = isset($values['name']) ? $values['name'] : '';
if (! $name) { if (! $name) {
throw new InvalidArgumentException(t('Authentication backend name missing')); throw new InvalidArgumentException($this->translate('Authentication backend name missing'));
} elseif ($this->config->hasSection($name)) { } elseif ($this->config->hasSection($name)) {
throw new InvalidArgumentException(t('Authentication backend already exists')); throw new InvalidArgumentException($this->translate('Authentication backend already exists'));
} }
unset($values['name']); unset($values['name']);
@ -114,11 +114,11 @@ class AuthenticationBackendConfigForm extends ConfigForm
public function edit($name, array $values) public function edit($name, array $values)
{ {
if (! $name) { if (! $name) {
throw new InvalidArgumentException(t('Old authentication backend name missing')); throw new InvalidArgumentException($this->translate('Old authentication backend name missing'));
} elseif (! ($newName = isset($values['name']) ? $values['name'] : '')) { } elseif (! ($newName = isset($values['name']) ? $values['name'] : '')) {
throw new InvalidArgumentException(t('New authentication backend name missing')); throw new InvalidArgumentException($this->translate('New authentication backend name missing'));
} elseif (! $this->config->hasSection($name)) { } elseif (! $this->config->hasSection($name)) {
throw new InvalidArgumentException(t('Unknown authentication backend provided')); throw new InvalidArgumentException($this->translate('Unknown authentication backend provided'));
} }
$backendConfig = $this->config->getSection($name); $backendConfig = $this->config->getSection($name);
@ -144,9 +144,9 @@ class AuthenticationBackendConfigForm extends ConfigForm
public function remove($name) public function remove($name)
{ {
if (! $name) { if (! $name) {
throw new InvalidArgumentException(t('Authentication backend name missing')); throw new InvalidArgumentException($this->translate('Authentication backend name missing'));
} elseif (! $this->config->hasSection($name)) { } elseif (! $this->config->hasSection($name)) {
throw new InvalidArgumentException(t('Unknown authentication backend provided')); throw new InvalidArgumentException($this->translate('Unknown authentication backend provided'));
} }
$backendConfig = $this->config->getSection($name); $backendConfig = $this->config->getSection($name);
@ -167,9 +167,9 @@ class AuthenticationBackendConfigForm extends ConfigForm
public function move($name, $position) public function move($name, $position)
{ {
if (! $name) { if (! $name) {
throw new InvalidArgumentException(t('Authentication backend name missing')); throw new InvalidArgumentException($this->translate('Authentication backend name missing'));
} elseif (! $this->config->hasSection($name)) { } elseif (! $this->config->hasSection($name)) {
throw new InvalidArgumentException(t('Unknown authentication backend provided')); throw new InvalidArgumentException($this->translate('Unknown authentication backend provided'));
} }
$backendOrder = $this->config->keys(); $backendOrder = $this->config->keys();
@ -208,10 +208,10 @@ class AuthenticationBackendConfigForm extends ConfigForm
try { try {
if ($authBackend === null) { // create new backend if ($authBackend === null) { // create new backend
$this->add($this->getValues()); $this->add($this->getValues());
$message = t('Authentication backend "%s" has been successfully created'); $message = $this->translate('Authentication backend "%s" has been successfully created');
} else { // edit existing backend } else { // edit existing backend
$this->edit($authBackend, $this->getValues()); $this->edit($authBackend, $this->getValues());
$message = t('Authentication backend "%s" has been successfully changed'); $message = $this->translate('Authentication backend "%s" has been successfully changed');
} }
} catch (InvalidArgumentException $e) { } catch (InvalidArgumentException $e) {
Notification::error($e->getMessage()); Notification::error($e->getMessage());
@ -237,11 +237,13 @@ class AuthenticationBackendConfigForm extends ConfigForm
$authBackend = $this->request->getQuery('auth_backend'); $authBackend = $this->request->getQuery('auth_backend');
if ($authBackend !== null) { if ($authBackend !== null) {
if ($authBackend === '') { if ($authBackend === '') {
throw new ConfigurationError(t('Authentication backend name missing')); throw new ConfigurationError($this->translate('Authentication backend name missing'));
} elseif (! $this->config->hasSection($authBackend)) { } elseif (! $this->config->hasSection($authBackend)) {
throw new ConfigurationError(t('Unknown authentication backend provided')); throw new ConfigurationError($this->translate('Unknown authentication backend provided'));
} elseif ($this->config->getSection($authBackend)->backend === null) { } elseif ($this->config->getSection($authBackend)->backend === null) {
throw new ConfigurationError(sprintf(t('Backend "%s" has no `backend\' setting'), $authBackend)); throw new ConfigurationError(
sprintf($this->translate('Backend "%s" has no `backend\' setting'), $authBackend)
);
} }
$configValues = $this->config->getSection($authBackend)->toArray(); $configValues = $this->config->getSection($authBackend)->toArray();
@ -257,7 +259,7 @@ class AuthenticationBackendConfigForm extends ConfigForm
); );
if (false === empty($autologinBackends)) { if (false === empty($autologinBackends)) {
throw new ConfigurationError(t('Could not find any resources for authentication')); throw new ConfigurationError($this->translate('Could not find any resources for authentication'));
} }
} }
} }
@ -276,8 +278,8 @@ class AuthenticationBackendConfigForm extends ConfigForm
array( array(
'order' => 0, 'order' => 0,
'ignore' => true, 'ignore' => true,
'label' => t('Force Changes'), 'label' => $this->translate('Force Changes'),
'description' => t('Check this box to enforce changes without connectivity validation') 'description' => $this->translate('Check this box to enforce changes without connectivity validation')
) )
); );
} }
@ -291,7 +293,7 @@ class AuthenticationBackendConfigForm extends ConfigForm
$backendType = isset($formData['type']) ? $formData['type'] : null; $backendType = isset($formData['type']) ? $formData['type'] : null;
if (isset($this->resources['db'])) { if (isset($this->resources['db'])) {
$backendTypes['db'] = t('Database'); $backendTypes['db'] = $this->translate('Database');
} }
if (isset($this->resources['ldap']) && ($backendType === 'ldap' || Platform::extensionLoaded('ldap'))) { if (isset($this->resources['ldap']) && ($backendType === 'ldap' || Platform::extensionLoaded('ldap'))) {
$backendTypes['ldap'] = 'LDAP'; $backendTypes['ldap'] = 'LDAP';
@ -304,7 +306,7 @@ class AuthenticationBackendConfigForm extends ConfigForm
} }
); );
if ($backendType === 'autologin' || empty($autologinBackends)) { if ($backendType === 'autologin' || empty($autologinBackends)) {
$backendTypes['autologin'] = t('Autologin'); $backendTypes['autologin'] = $this->translate('Autologin');
} }
if ($backendType === null) { if ($backendType === null) {
@ -318,8 +320,10 @@ class AuthenticationBackendConfigForm extends ConfigForm
'ignore' => true, 'ignore' => true,
'required' => true, 'required' => true,
'autosubmit' => true, 'autosubmit' => true,
'label' => t('Backend Type'), 'label' => $this->translate('Backend Type'),
'description' => t('The type of the resource to use for this authenticaton provider'), 'description' => $this->translate(
'The type of the resource to use for this authenticaton provider'
),
'multiOptions' => $backendTypes 'multiOptions' => $backendTypes
) )
); );

View File

@ -52,7 +52,7 @@ class AuthenticationBackendReorderForm extends ConfigForm
try { try {
if ($configForm->move($backendName, $position)->save()) { if ($configForm->move($backendName, $position)->save()) {
Notification::success(t('Authentication order updated!')); Notification::success($this->translate('Authentication order updated!'));
} else { } else {
return false; return false;
} }

View File

@ -33,10 +33,10 @@ class ApplicationConfigForm extends Form
'text', 'text',
'global_module_path', 'global_module_path',
array( array(
'label' => t('Module Path'), 'label' => $this->translate('Module Path'),
'required' => true, 'required' => true,
'value' => implode(':', Icinga::app()->getModuleManager()->getModuleDirs()), 'value' => implode(':', Icinga::app()->getModuleManager()->getModuleDirs()),
'description' => t( 'description' => $this->translate(
'Contains the directories that will be searched for available modules, separated by ' 'Contains the directories that will be searched for available modules, separated by '
. 'colons. Modules that don\'t exist in these directories can still be symlinked in ' . 'colons. Modules that don\'t exist in these directories can still be symlinked in '
. 'the module folder, but won\'t show up in the list of disabled modules.' . 'the module folder, but won\'t show up in the list of disabled modules.'
@ -50,11 +50,11 @@ class ApplicationConfigForm extends Form
array( array(
'required' => true, 'required' => true,
'autosubmit' => true, 'autosubmit' => true,
'label' => t('User Preference Storage Type'), 'label' => $this->translate('User Preference Storage Type'),
'multiOptions' => array( 'multiOptions' => array(
'ini' => t('File System (INI Files)'), 'ini' => $this->translate('File System (INI Files)'),
'db' => t('Database'), 'db' => $this->translate('Database'),
'null' => t('Don\'t Store Preferences') 'null' => $this->translate('Don\'t Store Preferences')
) )
) )
); );
@ -72,7 +72,7 @@ class ApplicationConfigForm extends Form
array( array(
'required' => true, 'required' => true,
'multiOptions' => $backends, 'multiOptions' => $backends,
'label' => t('Database Connection') 'label' => $this->translate('Database Connection')
) )
); );
} }

View File

@ -4,7 +4,6 @@
namespace Icinga\Forms\Config\General; namespace Icinga\Forms\Config\General;
use Icinga\Application\Icinga;
use Icinga\Application\Logger; use Icinga\Application\Logger;
use Icinga\Web\Form; use Icinga\Web\Form;
use Icinga\Web\Form\Validator\WritablePathValidator; use Icinga\Web\Form\Validator\WritablePathValidator;
@ -31,12 +30,12 @@ class LoggingConfigForm extends Form
array( array(
'required' => true, 'required' => true,
'autosubmit' => true, 'autosubmit' => true,
'label' => t('Logging Type'), 'label' => $this->translate('Logging Type'),
'description' => t('The type of logging to utilize.'), 'description' => $this->translate('The type of logging to utilize.'),
'multiOptions' => array( 'multiOptions' => array(
'syslog' => 'Syslog', 'syslog' => 'Syslog',
'file' => t('File', 'app.config.logging.type'), 'file' => $this->translate('File', 'app.config.logging.type'),
'none' => t('None', 'app.config.logging.type') 'none' => $this->translate('None', 'app.config.logging.type')
) )
) )
); );
@ -47,13 +46,13 @@ class LoggingConfigForm extends Form
'logging_level', 'logging_level',
array( array(
'required' => true, 'required' => true,
'label' => t('Logging Level'), 'label' => $this->translate('Logging Level'),
'description' => t('The maximum logging level to emit.'), 'description' => $this->translate('The maximum logging level to emit.'),
'multiOptions' => array( 'multiOptions' => array(
Logger::$levels[Logger::ERROR] => t('Error', 'app.config.logging.level'), Logger::$levels[Logger::ERROR] => $this->translate('Error', 'app.config.logging.level'),
Logger::$levels[Logger::WARNING] => t('Warning', 'app.config.logging.level'), Logger::$levels[Logger::WARNING] => $this->translate('Warning', 'app.config.logging.level'),
Logger::$levels[Logger::INFO] => t('Information', 'app.config.logging.level'), Logger::$levels[Logger::INFO] => $this->translate('Information', 'app.config.logging.level'),
Logger::$levels[Logger::DEBUG] => t('Debug', 'app.config.logging.level') Logger::$levels[Logger::DEBUG] => $this->translate('Debug', 'app.config.logging.level')
) )
) )
); );
@ -65,8 +64,10 @@ class LoggingConfigForm extends Form
'logging_application', 'logging_application',
array( array(
'required' => true, 'required' => true,
'label' => t('Application Prefix'), 'label' => $this->translate('Application Prefix'),
'description' => t('The name of the application by which to prefix syslog messages.'), 'description' => $this->translate(
'The name of the application by which to prefix syslog messages.'
),
'value' => 'icingaweb2', 'value' => 'icingaweb2',
'validators' => array( 'validators' => array(
array( array(
@ -91,8 +92,8 @@ class LoggingConfigForm extends Form
// 'logging_facility', // 'logging_facility',
// array( // array(
// 'required' => true, // 'required' => true,
// 'label' => t('Facility'), // 'label' => $this->translate('Facility'),
// 'description' => t('The syslog facility to utilize.'), // 'description' => $this->translate('The syslog facility to utilize.'),
// 'multiOptions' => array( // 'multiOptions' => array(
// 'user' => 'LOG_USER' // 'user' => 'LOG_USER'
// ) // )
@ -104,8 +105,8 @@ class LoggingConfigForm extends Form
'logging_file', 'logging_file',
array( array(
'required' => true, 'required' => true,
'label' => t('File path'), 'label' => $this->translate('File path'),
'description' => t('The full path to the log file to write messages to.'), 'description' => $this->translate('The full path to the log file to write messages to.'),
'value' => '/var/log/icingaweb2/icingaweb2.log', 'value' => '/var/log/icingaweb2/icingaweb2.log',
'validators' => array(new WritablePathValidator()) 'validators' => array(new WritablePathValidator())
) )

View File

@ -20,7 +20,7 @@ class GeneralConfigForm extends ConfigForm
public function init() public function init()
{ {
$this->setName('form_config_general'); $this->setName('form_config_general');
$this->setSubmitLabel(t('Save Changes')); $this->setSubmitLabel($this->translate('Save Changes'));
} }
/** /**
@ -52,7 +52,7 @@ class GeneralConfigForm extends ConfigForm
} }
if ($this->save()) { if ($this->save()) {
Notification::success(t('New configuration has successfully been stored')); Notification::success($this->translate('New configuration has successfully been stored'));
} else { } else {
return false; return false;
} }

View File

@ -41,8 +41,8 @@ class DbResourceForm extends Form
'name', 'name',
array( array(
'required' => true, 'required' => true,
'label' => t('Resource Name'), 'label' => $this->translate('Resource Name'),
'description' => t('The unique name of this resource') 'description' => $this->translate('The unique name of this resource')
) )
); );
$this->addElement( $this->addElement(
@ -50,8 +50,8 @@ class DbResourceForm extends Form
'db', 'db',
array( array(
'required' => true, 'required' => true,
'label' => t('Database Type'), 'label' => $this->translate('Database Type'),
'description' => t('The type of SQL database'), 'description' => $this->translate('The type of SQL database'),
'multiOptions' => $dbChoices 'multiOptions' => $dbChoices
) )
); );
@ -60,8 +60,8 @@ class DbResourceForm extends Form
'host', 'host',
array ( array (
'required' => true, 'required' => true,
'label' => t('Host'), 'label' => $this->translate('Host'),
'description' => t('The hostname of the database'), 'description' => $this->translate('The hostname of the database'),
'value' => 'localhost' 'value' => 'localhost'
) )
); );
@ -70,8 +70,8 @@ class DbResourceForm extends Form
'port', 'port',
array( array(
'required' => true, 'required' => true,
'label' => t('Port'), 'label' => $this->translate('Port'),
'description' => t('The port to use'), 'description' => $this->translate('The port to use'),
'value' => 3306 'value' => 3306
) )
); );
@ -80,8 +80,8 @@ class DbResourceForm extends Form
'dbname', 'dbname',
array( array(
'required' => true, 'required' => true,
'label' => t('Database Name'), 'label' => $this->translate('Database Name'),
'description' => t('The name of the database to use') 'description' => $this->translate('The name of the database to use')
) )
); );
$this->addElement( $this->addElement(
@ -89,8 +89,8 @@ class DbResourceForm extends Form
'username', 'username',
array ( array (
'required' => true, 'required' => true,
'label' => t('Username'), 'label' => $this->translate('Username'),
'description' => t('The user name to use for authentication') 'description' => $this->translate('The user name to use for authentication')
) )
); );
$this->addElement( $this->addElement(
@ -99,8 +99,8 @@ class DbResourceForm extends Form
array( array(
'required' => true, 'required' => true,
'renderPassword' => true, 'renderPassword' => true,
'label' => t('Password'), 'label' => $this->translate('Password'),
'description' => t('The password to use for authentication') 'description' => $this->translate('The password to use for authentication')
) )
); );
@ -132,7 +132,9 @@ class DbResourceForm extends Form
$resource = ResourceFactory::createResource(new ConfigObject($form->getValues())); $resource = ResourceFactory::createResource(new ConfigObject($form->getValues()));
$resource->getConnection()->getConnection(); $resource->getConnection()->getConnection();
} catch (Exception $e) { } catch (Exception $e) {
$form->addError(t('Connectivity validation failed, connection to the given resource not possible.')); $form->addError(
$this->translate('Connectivity validation failed, connection to the given resource not possible.')
);
return false; return false;
} }

View File

@ -30,8 +30,8 @@ class FileResourceForm extends Form
'name', 'name',
array( array(
'required' => true, 'required' => true,
'label' => t('Resource Name'), 'label' => $this->translate('Resource Name'),
'description' => t('The unique name of this resource') 'description' => $this->translate('The unique name of this resource')
) )
); );
$this->addElement( $this->addElement(
@ -39,8 +39,8 @@ class FileResourceForm extends Form
'filename', 'filename',
array( array(
'required' => true, 'required' => true,
'label' => t('Filepath'), 'label' => $this->translate('Filepath'),
'description' => t('The filename to fetch information from'), 'description' => $this->translate('The filename to fetch information from'),
'validators' => array(new ReadablePathValidator()) 'validators' => array(new ReadablePathValidator())
) )
); );
@ -49,8 +49,8 @@ class FileResourceForm extends Form
'fields', 'fields',
array( array(
'required' => true, 'required' => true,
'label' => t('Pattern'), 'label' => $this->translate('Pattern'),
'description' => t('The regular expression by which to identify columns') 'description' => $this->translate('The regular expression by which to identify columns')
) )
); );

View File

@ -32,8 +32,8 @@ class LdapResourceForm extends Form
'name', 'name',
array( array(
'required' => true, 'required' => true,
'label' => t('Resource Name'), 'label' => $this->translate('Resource Name'),
'description' => t('The unique name of this resource') 'description' => $this->translate('The unique name of this resource')
) )
); );
$this->addElement( $this->addElement(
@ -41,8 +41,10 @@ class LdapResourceForm extends Form
'hostname', 'hostname',
array( array(
'required' => true, 'required' => true,
'label' => t('Host'), 'label' => $this->translate('Host'),
'description' => t('The hostname or address of the LDAP server to use for authentication'), 'description' => $this->translate(
'The hostname or address of the LDAP server to use for authentication'
),
'value' => 'localhost' 'value' => 'localhost'
) )
); );
@ -51,8 +53,8 @@ class LdapResourceForm extends Form
'port', 'port',
array( array(
'required' => true, 'required' => true,
'label' => t('Port'), 'label' => $this->translate('Port'),
'description' => t('The port of the LDAP server to use for authentication'), 'description' => $this->translate('The port of the LDAP server to use for authentication'),
'value' => 389 'value' => 389
) )
); );
@ -61,8 +63,10 @@ class LdapResourceForm extends Form
'root_dn', 'root_dn',
array( array(
'required' => true, 'required' => true,
'label' => t('Root DN'), 'label' => $this->translate('Root DN'),
'description' => t('Only the root and its child nodes will be accessible on this resource.') 'description' => $this->translate(
'Only the root and its child nodes will be accessible on this resource.'
)
) )
); );
$this->addElement( $this->addElement(
@ -70,8 +74,8 @@ class LdapResourceForm extends Form
'bind_dn', 'bind_dn',
array( array(
'required' => true, 'required' => true,
'label' => t('Bind DN'), 'label' => $this->translate('Bind DN'),
'description' => t('The user dn to use for querying the ldap server') 'description' => $this->translate('The user dn to use for querying the ldap server')
) )
); );
$this->addElement( $this->addElement(
@ -80,8 +84,8 @@ class LdapResourceForm extends Form
array( array(
'required' => true, 'required' => true,
'renderPassword' => true, 'renderPassword' => true,
'label' => t('Bind Password'), 'label' => $this->translate('Bind Password'),
'description' => t('The password to use for querying the ldap server') 'description' => $this->translate('The password to use for querying the ldap server')
) )
); );
@ -119,7 +123,9 @@ class LdapResourceForm extends Form
throw new Exception(); throw new Exception();
} }
} catch (Exception $e) { } catch (Exception $e) {
$form->addError(t('Connectivity validation failed, connection to the given resource not possible.')); $form->addError(
$this->translate('Connectivity validation failed, connection to the given resource not possible.')
);
return false; return false;
} }

View File

@ -33,8 +33,8 @@ class LivestatusResourceForm extends Form
'name', 'name',
array( array(
'required' => true, 'required' => true,
'label' => t('Resource Name'), 'label' => $this->translate('Resource Name'),
'description' => t('The unique name of this resource') 'description' => $this->translate('The unique name of this resource')
) )
); );
$this->addElement( $this->addElement(
@ -42,8 +42,8 @@ class LivestatusResourceForm extends Form
'socket', 'socket',
array( array(
'required' => true, 'required' => true,
'label' => t('Socket'), 'label' => $this->translate('Socket'),
'description' => t('The path to your livestatus socket used for querying monitoring data'), 'description' => $this->translate('The path to your livestatus socket used for querying monitoring data'),
'value' => '/var/run/icinga2/cmd/livestatus' 'value' => '/var/run/icinga2/cmd/livestatus'
) )
); );
@ -75,8 +75,10 @@ class LivestatusResourceForm extends Form
try { try {
$resource = ResourceFactory::createResource(new ConfigObject($form->getValues())); $resource = ResourceFactory::createResource(new ConfigObject($form->getValues()));
$resource->connect()->disconnect(); $resource->connect()->disconnect();
} catch (Exception $e) { } catch (Exception $_) {
$form->addError(t('Connectivity validation failed, connection to the given resource not possible.')); $form->addError(
$this->translate('Connectivity validation failed, connection to the given resource not possible.')
);
return false; return false;
} }

View File

@ -22,7 +22,7 @@ class ResourceConfigForm extends ConfigForm
public function init() public function init()
{ {
$this->setName('form_config_resource'); $this->setName('form_config_resource');
$this->setSubmitLabel(t('Save Changes')); $this->setSubmitLabel($this->translate('Save Changes'));
} }
/** /**
@ -43,7 +43,7 @@ class ResourceConfigForm extends ConfigForm
} elseif ($type === 'file') { } elseif ($type === 'file') {
return new FileResourceForm(); return new FileResourceForm();
} else { } else {
throw new InvalidArgumentException(sprintf(t('Invalid resource type "%s" provided'), $type)); throw new InvalidArgumentException(sprintf($this->translate('Invalid resource type "%s" provided'), $type));
} }
} }
@ -62,9 +62,9 @@ class ResourceConfigForm extends ConfigForm
{ {
$name = isset($values['name']) ? $values['name'] : ''; $name = isset($values['name']) ? $values['name'] : '';
if (! $name) { if (! $name) {
throw new InvalidArgumentException(t('Resource name missing')); throw new InvalidArgumentException($this->translate('Resource name missing'));
} elseif ($this->config->hasSection($name)) { } elseif ($this->config->hasSection($name)) {
throw new InvalidArgumentException(t('Resource already exists')); throw new InvalidArgumentException($this->translate('Resource already exists'));
} }
unset($values['name']); unset($values['name']);
@ -85,11 +85,11 @@ class ResourceConfigForm extends ConfigForm
public function edit($name, array $values) public function edit($name, array $values)
{ {
if (! $name) { if (! $name) {
throw new InvalidArgumentException(t('Old resource name missing')); throw new InvalidArgumentException($this->translate('Old resource name missing'));
} elseif (! ($newName = isset($values['name']) ? $values['name'] : '')) { } elseif (! ($newName = isset($values['name']) ? $values['name'] : '')) {
throw new InvalidArgumentException(t('New resource name missing')); throw new InvalidArgumentException($this->translate('New resource name missing'));
} elseif (! $this->config->hasSection($name)) { } elseif (! $this->config->hasSection($name)) {
throw new InvalidArgumentException(t('Unknown resource provided')); throw new InvalidArgumentException($this->translate('Unknown resource provided'));
} }
$resourceConfig = $this->config->getSection($name); $resourceConfig = $this->config->getSection($name);
@ -111,9 +111,9 @@ class ResourceConfigForm extends ConfigForm
public function remove($name) public function remove($name)
{ {
if (! $name) { if (! $name) {
throw new InvalidArgumentException(t('Resource name missing')); throw new InvalidArgumentException($this->translate('Resource name missing'));
} elseif (! $this->config->hasSection($name)) { } elseif (! $this->config->hasSection($name)) {
throw new InvalidArgumentException(t('Unknown resource provided')); throw new InvalidArgumentException($this->translate('Unknown resource provided'));
} }
$resourceConfig = $this->config->getSection($name); $resourceConfig = $this->config->getSection($name);
@ -143,10 +143,10 @@ class ResourceConfigForm extends ConfigForm
try { try {
if ($resource === null) { // create new resource if ($resource === null) { // create new resource
$this->add($this->getValues()); $this->add($this->getValues());
$message = t('Resource "%s" has been successfully created'); $message = $this->translate('Resource "%s" has been successfully created');
} else { // edit existing resource } else { // edit existing resource
$this->edit($resource, $this->getValues()); $this->edit($resource, $this->getValues());
$message = t('Resource "%s" has been successfully changed'); $message = $this->translate('Resource "%s" has been successfully changed');
} }
} catch (InvalidArgumentException $e) { } catch (InvalidArgumentException $e) {
Notification::error($e->getMessage()); Notification::error($e->getMessage());
@ -172,9 +172,9 @@ class ResourceConfigForm extends ConfigForm
$resource = $this->request->getQuery('resource'); $resource = $this->request->getQuery('resource');
if ($resource !== null) { if ($resource !== null) {
if ($resource === '') { if ($resource === '') {
throw new ConfigurationError(t('Resource name missing')); throw new ConfigurationError($this->translate('Resource name missing'));
} elseif (! $this->config->hasSection($resource)) { } elseif (! $this->config->hasSection($resource)) {
throw new ConfigurationError(t('Unknown resource provided')); throw new ConfigurationError($this->translate('Unknown resource provided'));
} }
$configValues = $this->config->getSection($resource)->toArray(); $configValues = $this->config->getSection($resource)->toArray();
@ -197,8 +197,8 @@ class ResourceConfigForm extends ConfigForm
array( array(
'order' => 0, 'order' => 0,
'ignore' => true, 'ignore' => true,
'label' => t('Force Changes'), 'label' => $this->translate('Force Changes'),
'description' => t('Check this box to enforce changes without connectivity validation') 'description' => $this->translate('Check this box to enforce changes without connectivity validation')
) )
); );
} }
@ -211,14 +211,14 @@ class ResourceConfigForm extends ConfigForm
$resourceType = isset($formData['type']) ? $formData['type'] : 'db'; $resourceType = isset($formData['type']) ? $formData['type'] : 'db';
$resourceTypes = array( $resourceTypes = array(
'file' => t('File'), 'file' => $this->translate('File'),
'livestatus' => 'Livestatus', 'livestatus' => 'Livestatus',
); );
if ($resourceType === 'ldap' || Platform::extensionLoaded('ldap')) { if ($resourceType === 'ldap' || Platform::extensionLoaded('ldap')) {
$resourceTypes['ldap'] = 'LDAP'; $resourceTypes['ldap'] = 'LDAP';
} }
if ($resourceType === 'db' || Platform::hasMysqlSupport() || Platform::hasPostgresqlSupport()) { if ($resourceType === 'db' || Platform::hasMysqlSupport() || Platform::hasPostgresqlSupport()) {
$resourceTypes['db'] = t('SQL Database'); $resourceTypes['db'] = $this->translate('SQL Database');
} }
$this->addElement( $this->addElement(
@ -227,8 +227,8 @@ class ResourceConfigForm extends ConfigForm
array( array(
'required' => true, 'required' => true,
'autosubmit' => true, 'autosubmit' => true,
'label' => t('Resource Type'), 'label' => $this->translate('Resource Type'),
'description' => t('The type of resource'), 'description' => $this->translate('The type of resource'),
'multiOptions' => $resourceTypes, 'multiOptions' => $resourceTypes,
'value' => $resourceType 'value' => $resourceType
) )

View File

@ -17,6 +17,6 @@ class ConfirmRemovalForm extends Form
public function init() public function init()
{ {
$this->setName('form_confirm_removal'); $this->setName('form_confirm_removal');
$this->setSubmitLabel(t('Confirm Removal')); $this->setSubmitLabel($this->translate('Confirm Removal'));
} }
} }

View File

@ -26,7 +26,7 @@ class DashletForm extends Form
{ {
$this->setName('form_dashboard_addurl'); $this->setName('form_dashboard_addurl');
if (! $this->getSubmitLabel()) { if (! $this->getSubmitLabel()) {
$this->setSubmitLabel(t('Add To Dashboard')); $this->setSubmitLabel($this->translate('Add To Dashboard'));
} }
$this->setAction(URL::fromRequest()); $this->setAction(URL::fromRequest());
} }
@ -66,9 +66,10 @@ class DashletForm extends Form
'url', 'url',
array( array(
'required' => true, 'required' => true,
'label' => t('Url'), 'label' => $this->translate('Url'),
'description' => 'description' => $this->translate(
t('Enter url being loaded in the dashlet. You can paste the full URL, including filters.') 'Enter url being loaded in the dashlet. You can paste the full URL, including filters.'
)
) )
); );
$this->addElement( $this->addElement(
@ -76,8 +77,8 @@ class DashletForm extends Form
'dashlet', 'dashlet',
array( array(
'required' => true, 'required' => true,
'label' => t('Dashlet Title'), 'label' => $this->translate('Dashlet Title'),
'description' => t('Enter a title for the dashlet.') 'description' => $this->translate('Enter a title for the dashlet.')
) )
); );
$this->addElement( $this->addElement(
@ -95,9 +96,8 @@ class DashletForm extends Form
'pane', 'pane',
array( array(
'required' => true, 'required' => true,
'label' => t("New Dashboard Title"), 'label' => $this->translate("New Dashboard Title"),
'description' => 'description' => $this->translate('Enter a title for the new pane.')
t('Enter a title for the new pane.')
) )
); );
} else { } else {
@ -106,10 +106,9 @@ class DashletForm extends Form
'pane', 'pane',
array( array(
'required' => true, 'required' => true,
'label' => t('Dashboard'), 'label' => $this->translate('Dashboard'),
'multiOptions' => $panes, 'multiOptions' => $panes,
'description' => 'description' => $this->translate('Select a pane you want to add the dashlet.')
t('Select a pane you want to add the dashlet.')
) )
); );
} }
@ -119,9 +118,9 @@ class DashletForm extends Form
'create_new_pane', 'create_new_pane',
array( array(
'required' => false, 'required' => false,
'label' => t('New dashboard'), 'label' => $this->translate('New dashboard'),
'class' => 'autosubmit', 'class' => 'autosubmit',
'description' => t('Check this box if you want to add the dashlet to a new dashboard') 'description' => $this->translate('Check this box if you want to add the dashlet to a new dashboard')
) )
); );
} }

View File

@ -26,8 +26,8 @@ class LdapDiscoveryForm extends Form
'domain', 'domain',
array( array(
'required' => true, 'required' => true,
'label' => t('Search Domain'), 'label' => $this->translate('Search Domain'),
'description' => t('Search this domain for records of available servers.'), 'description' => $this->translate('Search this domain for records of available servers.'),
) )
); );
@ -36,7 +36,7 @@ class LdapDiscoveryForm extends Form
'note', 'note',
'additional_description', 'additional_description',
array( array(
'value' => t('No Ldap servers found on this domain.' 'value' => $this->translate('No Ldap servers found on this domain.'
. ' You can try to specify host and port and try again, or just skip this step and ' . ' You can try to specify host and port and try again, or just skip this step and '
. 'configure the server manually.' . 'configure the server manually.'
) )
@ -47,8 +47,8 @@ class LdapDiscoveryForm extends Form
'hostname', 'hostname',
array( array(
'required' => false, 'required' => false,
'label' => t('Host'), 'label' => $this->translate('Host'),
'description' => t('IP or host name to search.'), 'description' => $this->translate('IP or host name to search.'),
) )
); );
@ -57,8 +57,8 @@ class LdapDiscoveryForm extends Form
'port', 'port',
array( array(
'required' => false, 'required' => false,
'label' => t('Port'), 'label' => $this->translate('Port'),
'description' => t('Port', 389), 'description' => $this->translate('Port', 389),
) )
); );
} }

View File

@ -105,9 +105,9 @@ class PreferenceForm extends Form
try { try {
if ($this->getElement('btn_submit_preferences')->isChecked()) { if ($this->getElement('btn_submit_preferences')->isChecked()) {
$this->save(); $this->save();
Notification::success(t('Preferences successfully saved')); Notification::success($this->translate('Preferences successfully saved'));
} else { } else {
Notification::success(t('Preferences successfully saved for the current session')); Notification::success($this->translate('Preferences successfully saved for the current session'));
} }
} catch (Exception $e) { } catch (Exception $e) {
Logger::error($e); Logger::error($e);
@ -142,13 +142,13 @@ class PreferenceForm extends Form
public function createElements(array $formData) public function createElements(array $formData)
{ {
$languages = array(); $languages = array();
$languages['autodetect'] = sprintf(t('Browser (%s)', 'preferences.form'), $this->getLocale()); $languages['autodetect'] = sprintf($this->translate('Browser (%s)', 'preferences.form'), $this->getLocale());
foreach (Translator::getAvailableLocaleCodes() as $language) { foreach (Translator::getAvailableLocaleCodes() as $language) {
$languages[$language] = $language; $languages[$language] = $language;
} }
$tzList = array(); $tzList = array();
$tzList['autodetect'] = sprintf(t('Browser (%s)', 'preferences.form'), $this->getDefaultTimezone()); $tzList['autodetect'] = sprintf($this->translate('Browser (%s)', 'preferences.form'), $this->getDefaultTimezone());
foreach (DateTimeZone::listIdentifiers() as $tz) { foreach (DateTimeZone::listIdentifiers() as $tz) {
$tzList[$tz] = $tz; $tzList[$tz] = $tz;
} }
@ -158,8 +158,8 @@ class PreferenceForm extends Form
'language', 'language',
array( array(
'required' => true, 'required' => true,
'label' => t('Your Current Language'), 'label' => $this->translate('Your Current Language'),
'description' => t('Use the following language to display texts and messages'), 'description' => $this->translate('Use the following language to display texts and messages'),
'multiOptions' => $languages, 'multiOptions' => $languages,
'value' => substr(setlocale(LC_ALL, 0), 0, 5) 'value' => substr(setlocale(LC_ALL, 0), 0, 5)
) )
@ -170,8 +170,8 @@ class PreferenceForm extends Form
'timezone', 'timezone',
array( array(
'required' => true, 'required' => true,
'label' => t('Your Current Timezone'), 'label' => $this->translate('Your Current Timezone'),
'description' => t('Use the following timezone for dates and times'), 'description' => $this->translate('Use the following timezone for dates and times'),
'multiOptions' => $tzList, 'multiOptions' => $tzList,
'value' => $this->getDefaultTimezone() 'value' => $this->getDefaultTimezone()
) )
@ -182,7 +182,7 @@ class PreferenceForm extends Form
'show_benchmark', 'show_benchmark',
array( array(
'required' => true, 'required' => true,
'label' => t('Use benchmark') 'label' => $this->translate('Use benchmark')
) )
); );
@ -191,7 +191,7 @@ class PreferenceForm extends Form
'btn_submit_preferences', 'btn_submit_preferences',
array( array(
'ignore' => true, 'ignore' => true,
'label' => t('Save to the Preferences'), 'label' => $this->translate('Save to the Preferences'),
'decorators' => array( 'decorators' => array(
'ViewHelper', 'ViewHelper',
array('HtmlTag', array('tag' => 'div')) array('HtmlTag', array('tag' => 'div'))
@ -204,7 +204,7 @@ class PreferenceForm extends Form
'btn_submit_session', 'btn_submit_session',
array( array(
'ignore' => true, 'ignore' => true,
'label' => t('Save for the current Session'), 'label' => $this->translate('Save for the current Session'),
'decorators' => array( 'decorators' => array(
'ViewHelper', 'ViewHelper',
array('HtmlTag', array('tag' => 'div')) array('HtmlTag', array('tag' => 'div'))

View File

@ -72,8 +72,8 @@ class RoleForm extends ConfigForm
'name', 'name',
array( array(
'required' => true, 'required' => true,
'label' => t('Role Name'), 'label' => $this->translate('Role Name'),
'description' => t('The name of the role'), 'description' => $this->translate('The name of the role'),
'ignore' => true 'ignore' => true
), ),
), ),
@ -81,24 +81,26 @@ class RoleForm extends ConfigForm
'textarea', 'textarea',
'users', 'users',
array( array(
'label' => t('Users'), 'label' => $this->translate('Users'),
'description' => t('Comma-separated list of users that are assigned to the role') 'description' => $this->translate('Comma-separated list of users that are assigned to the role')
), ),
), ),
array( array(
'textarea', 'textarea',
'groups', 'groups',
array( array(
'label' => t('Groups'), 'label' => $this->translate('Groups'),
'description' => t('Comma-separated list of groups that are assigned to the role') 'description' => $this->translate('Comma-separated list of groups that are assigned to the role')
), ),
), ),
array( array(
'multiselect', 'multiselect',
'permissions', 'permissions',
array( array(
'label' => t('Permissions Set'), 'label' => $this->translate('Permissions Set'),
'description' => t('The permissions to grant. You may select more than one permission'), 'description' => $this->translate(
'The permissions to grant. You may select more than one permission'
),
'multiOptions' => $this->providedPermissions 'multiOptions' => $this->providedPermissions
) )
) )
@ -133,7 +135,7 @@ class RoleForm extends ConfigForm
} }
if (! $this->config->hasSection($name)) { if (! $this->config->hasSection($name)) {
throw new InvalidArgumentException(sprintf( throw new InvalidArgumentException(sprintf(
t('Can\'t load role \'%s\'. Role does not exist'), $this->translate('Can\'t load role \'%s\'. Role does not exist'),
$name $name
)); ));
} }
@ -174,7 +176,7 @@ class RoleForm extends ConfigForm
} }
if ($this->config->hasSection($name)) { if ($this->config->hasSection($name)) {
throw new InvalidArgumentException(sprintf( throw new InvalidArgumentException(sprintf(
t('Can\'t add role \'%s\'. Role already exists'), $this->translate('Can\'t add role \'%s\'. Role already exists'),
$name $name
)); ));
} }
@ -200,7 +202,7 @@ class RoleForm extends ConfigForm
} }
if (! $this->config->hasSection($name)) { if (! $this->config->hasSection($name)) {
throw new InvalidArgumentException(sprintf( throw new InvalidArgumentException(sprintf(
t('Can\'t remove role \'%s\'. Role does not exist'), $this->translate('Can\'t remove role \'%s\'. Role does not exist'),
$name $name
)); ));
} }
@ -233,7 +235,7 @@ class RoleForm extends ConfigForm
} else { } else {
if (! $this->config->hasSection($name)) { if (! $this->config->hasSection($name)) {
throw new InvalidArgumentException(sprintf( throw new InvalidArgumentException(sprintf(
t('Can\'t update role \'%s\'. Role does not exist'), $this->translate('Can\'t update role \'%s\'. Role does not exist'),
$name $name
)); ));
} }