From dbd69ba6935fb59de471123f3f55b01ad58ca167 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 19 Jan 2015 11:26:23 +0100 Subject: [PATCH] Replace t() and mt() with translate() in the application's forms refs #7551 --- .../forms/Authentication/LoginForm.php | 10 ++-- .../Authentication/AutologinBackendForm.php | 8 +-- .../Config/Authentication/DbBackendForm.php | 14 +++--- .../Config/Authentication/LdapBackendForm.php | 28 ++++++----- .../AuthenticationBackendConfigForm.php | 50 ++++++++++--------- .../AuthenticationBackendReorderForm.php | 2 +- .../Config/General/ApplicationConfigForm.php | 14 +++--- .../Config/General/LoggingConfigForm.php | 35 ++++++------- .../forms/Config/GeneralConfigForm.php | 4 +- .../forms/Config/Resource/DbResourceForm.php | 32 ++++++------ .../Config/Resource/FileResourceForm.php | 12 ++--- .../Config/Resource/LdapResourceForm.php | 32 +++++++----- .../Resource/LivestatusResourceForm.php | 14 +++--- .../forms/Config/ResourceConfigForm.php | 38 +++++++------- application/forms/ConfirmRemovalForm.php | 2 +- application/forms/Dashboard/DashletForm.php | 27 +++++----- application/forms/LdapDiscoveryForm.php | 14 +++--- application/forms/PreferenceForm.php | 22 ++++---- application/forms/Security/RoleForm.php | 26 +++++----- 19 files changed, 203 insertions(+), 181 deletions(-) diff --git a/application/forms/Authentication/LoginForm.php b/application/forms/Authentication/LoginForm.php index a6d69d15a..8be455dcc 100644 --- a/application/forms/Authentication/LoginForm.php +++ b/application/forms/Authentication/LoginForm.php @@ -18,7 +18,7 @@ class LoginForm extends Form public function init() { $this->setName('form_login'); - $this->setSubmitLabel(t('Login')); + $this->setSubmitLabel($this->translate('Login')); } /** @@ -31,8 +31,8 @@ class LoginForm extends Form 'username', array( 'required' => true, - 'label' => t('Username'), - 'placeholder' => t('Please enter your username...'), + 'label' => $this->translate('Username'), + 'placeholder' => $this->translate('Please enter your username...'), 'class' => false === isset($formData['username']) ? 'autofocus' : '' ) ); @@ -41,8 +41,8 @@ class LoginForm extends Form 'password', array( 'required' => true, - 'label' => t('Password'), - 'placeholder' => t('...and your password'), + 'label' => $this->translate('Password'), + 'placeholder' => $this->translate('...and your password'), 'class' => isset($formData['username']) ? 'autofocus' : '' ) ); diff --git a/application/forms/Config/Authentication/AutologinBackendForm.php b/application/forms/Config/Authentication/AutologinBackendForm.php index 97b5dfed7..cd09d38ac 100644 --- a/application/forms/Config/Authentication/AutologinBackendForm.php +++ b/application/forms/Config/Authentication/AutologinBackendForm.php @@ -30,8 +30,8 @@ class AutologinBackendForm extends Form 'name', array( 'required' => true, - 'label' => t('Backend Name'), - 'description' => t( + 'label' => $this->translate('Backend Name'), + 'description' => $this->translate( 'The name of this authentication provider that is used to differentiate it from others' ), 'validators' => array( @@ -52,8 +52,8 @@ class AutologinBackendForm extends Form 'text', 'strip_username_regexp', array( - 'label' => t('Filter Pattern'), - 'description' => t( + 'label' => $this->translate('Filter Pattern'), + 'description' => $this->translate( 'The regular expression to use to strip specific parts off from usernames.' . ' Leave empty if you do not want to strip off anything' ), diff --git a/application/forms/Config/Authentication/DbBackendForm.php b/application/forms/Config/Authentication/DbBackendForm.php index 572a09c2e..f8a4fb832 100644 --- a/application/forms/Config/Authentication/DbBackendForm.php +++ b/application/forms/Config/Authentication/DbBackendForm.php @@ -53,8 +53,8 @@ class DbBackendForm extends Form 'name', array( 'required' => true, - 'label' => t('Backend Name'), - 'description' => t( + 'label' => $this->translate('Backend Name'), + 'description' => $this->translate( 'The name of this authentication provider that is used to differentiate it from others' ), ) @@ -64,8 +64,10 @@ class DbBackendForm extends Form 'resource', array( 'required' => true, - 'label' => t('Database Connection'), - 'description' => t('The database connection to use for authenticating with this provider'), + 'label' => $this->translate('Database Connection'), + 'description' => $this->translate( + 'The database connection to use for authenticating with this provider' + ), 'multiOptions' => false === empty($this->resources) ? array_combine($this->resources, $this->resources) : array() @@ -107,11 +109,11 @@ class DbBackendForm extends Form try { $dbUserBackend = new DbUserBackend(ResourceFactory::createResource($form->getResourceConfig())); 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; } } 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; } diff --git a/application/forms/Config/Authentication/LdapBackendForm.php b/application/forms/Config/Authentication/LdapBackendForm.php index 9b48c3dbc..5915a0a10 100644 --- a/application/forms/Config/Authentication/LdapBackendForm.php +++ b/application/forms/Config/Authentication/LdapBackendForm.php @@ -54,8 +54,8 @@ class LdapBackendForm extends Form 'name', array( 'required' => true, - 'label' => t('Backend Name'), - 'description' => t( + 'label' => $this->translate('Backend Name'), + 'description' => $this->translate( 'The name of this authentication provider that is used to differentiate it from others' ) ) @@ -65,8 +65,8 @@ class LdapBackendForm extends Form 'resource', array( 'required' => true, - 'label' => t('LDAP Resource'), - 'description' => t('The resource to use for authenticating with this provider'), + 'label' => $this->translate('LDAP Resource'), + 'description' => $this->translate('The resource to use for authenticating with this provider'), 'multiOptions' => false === empty($this->resources) ? array_combine($this->resources, $this->resources) : array() @@ -77,8 +77,8 @@ class LdapBackendForm extends Form 'user_class', array( 'required' => true, - 'label' => t('LDAP User Object Class'), - 'description' => t('The object class used for storing users on the ldap server'), + 'label' => $this->translate('LDAP User Object Class'), + 'description' => $this->translate('The object class used for storing users on the ldap server'), 'value' => 'inetOrgPerson' ) ); @@ -87,8 +87,10 @@ class LdapBackendForm extends Form 'user_name_attribute', array( 'required' => true, - 'label' => t('LDAP User Name Attribute'), - 'description' => t('The attribute name used for storing the user name on the ldap server'), + 'label' => $this->translate('LDAP User Name Attribute'), + 'description' => $this->translate( + 'The attribute name used for storing the user name on the ldap server' + ), 'value' => 'uid' ) ); @@ -105,9 +107,11 @@ class LdapBackendForm extends Form 'base_dn', array( 'required' => false, - 'label' => t('Base DN'), - 'description' => t('The path where users can be found on the ldap server. ' . - ' Leave empty to select all users available on the specified resource.') + 'label' => $this->translate('Base DN'), + 'description' => $this->translate( + 'The path where users can be found on the ldap server. Leave ' . + 'empty to select all users available on the specified resource.' + ) ) ); return $this; @@ -146,7 +150,7 @@ class LdapBackendForm extends Form $form->addError($e->getMessage()); return false; } 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; } diff --git a/application/forms/Config/AuthenticationBackendConfigForm.php b/application/forms/Config/AuthenticationBackendConfigForm.php index 12f407c69..076f8cb17 100644 --- a/application/forms/Config/AuthenticationBackendConfigForm.php +++ b/application/forms/Config/AuthenticationBackendConfigForm.php @@ -31,7 +31,7 @@ class AuthenticationBackendConfigForm extends ConfigForm public function init() { $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') { $form = new AutologinBackendForm(); } 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; @@ -91,9 +91,9 @@ class AuthenticationBackendConfigForm extends ConfigForm { $name = isset($values['name']) ? $values['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)) { - throw new InvalidArgumentException(t('Authentication backend already exists')); + throw new InvalidArgumentException($this->translate('Authentication backend already exists')); } unset($values['name']); @@ -114,11 +114,11 @@ class AuthenticationBackendConfigForm extends ConfigForm public function edit($name, array $values) { 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'] : '')) { - throw new InvalidArgumentException(t('New authentication backend name missing')); + throw new InvalidArgumentException($this->translate('New authentication backend name missing')); } 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); @@ -144,9 +144,9 @@ class AuthenticationBackendConfigForm extends ConfigForm public function remove($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)) { - throw new InvalidArgumentException(t('Unknown authentication backend provided')); + throw new InvalidArgumentException($this->translate('Unknown authentication backend provided')); } $backendConfig = $this->config->getSection($name); @@ -167,9 +167,9 @@ class AuthenticationBackendConfigForm extends ConfigForm public function move($name, $position) { if (! $name) { - throw new InvalidArgumentException(t('Authentication backend name missing')); + throw new InvalidArgumentException($this->translate('Authentication backend name missing')); } 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(); @@ -208,10 +208,10 @@ class AuthenticationBackendConfigForm extends ConfigForm try { if ($authBackend === null) { // create new backend $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 $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) { Notification::error($e->getMessage()); @@ -237,11 +237,13 @@ class AuthenticationBackendConfigForm extends ConfigForm $authBackend = $this->request->getQuery('auth_backend'); if ($authBackend !== null) { if ($authBackend === '') { - throw new ConfigurationError(t('Authentication backend name missing')); + throw new ConfigurationError($this->translate('Authentication backend name missing')); } 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) { - 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(); @@ -257,7 +259,7 @@ class AuthenticationBackendConfigForm extends ConfigForm ); 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( 'order' => 0, 'ignore' => true, - 'label' => t('Force Changes'), - 'description' => t('Check this box to enforce changes without connectivity validation') + 'label' => $this->translate('Force Changes'), + '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; if (isset($this->resources['db'])) { - $backendTypes['db'] = t('Database'); + $backendTypes['db'] = $this->translate('Database'); } if (isset($this->resources['ldap']) && ($backendType === 'ldap' || Platform::extensionLoaded('ldap'))) { $backendTypes['ldap'] = 'LDAP'; @@ -304,7 +306,7 @@ class AuthenticationBackendConfigForm extends ConfigForm } ); if ($backendType === 'autologin' || empty($autologinBackends)) { - $backendTypes['autologin'] = t('Autologin'); + $backendTypes['autologin'] = $this->translate('Autologin'); } if ($backendType === null) { @@ -318,8 +320,10 @@ class AuthenticationBackendConfigForm extends ConfigForm 'ignore' => true, 'required' => true, 'autosubmit' => true, - 'label' => t('Backend Type'), - 'description' => t('The type of the resource to use for this authenticaton provider'), + 'label' => $this->translate('Backend Type'), + 'description' => $this->translate( + 'The type of the resource to use for this authenticaton provider' + ), 'multiOptions' => $backendTypes ) ); diff --git a/application/forms/Config/AuthenticationBackendReorderForm.php b/application/forms/Config/AuthenticationBackendReorderForm.php index 07200827a..a41224248 100644 --- a/application/forms/Config/AuthenticationBackendReorderForm.php +++ b/application/forms/Config/AuthenticationBackendReorderForm.php @@ -52,7 +52,7 @@ class AuthenticationBackendReorderForm extends ConfigForm try { if ($configForm->move($backendName, $position)->save()) { - Notification::success(t('Authentication order updated!')); + Notification::success($this->translate('Authentication order updated!')); } else { return false; } diff --git a/application/forms/Config/General/ApplicationConfigForm.php b/application/forms/Config/General/ApplicationConfigForm.php index 95ad22071..8f718ccdf 100644 --- a/application/forms/Config/General/ApplicationConfigForm.php +++ b/application/forms/Config/General/ApplicationConfigForm.php @@ -33,10 +33,10 @@ class ApplicationConfigForm extends Form 'text', 'global_module_path', array( - 'label' => t('Module Path'), + 'label' => $this->translate('Module Path'), 'required' => true, 'value' => implode(':', Icinga::app()->getModuleManager()->getModuleDirs()), - 'description' => t( + 'description' => $this->translate( '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 ' . 'the module folder, but won\'t show up in the list of disabled modules.' @@ -50,11 +50,11 @@ class ApplicationConfigForm extends Form array( 'required' => true, 'autosubmit' => true, - 'label' => t('User Preference Storage Type'), + 'label' => $this->translate('User Preference Storage Type'), 'multiOptions' => array( - 'ini' => t('File System (INI Files)'), - 'db' => t('Database'), - 'null' => t('Don\'t Store Preferences') + 'ini' => $this->translate('File System (INI Files)'), + 'db' => $this->translate('Database'), + 'null' => $this->translate('Don\'t Store Preferences') ) ) ); @@ -72,7 +72,7 @@ class ApplicationConfigForm extends Form array( 'required' => true, 'multiOptions' => $backends, - 'label' => t('Database Connection') + 'label' => $this->translate('Database Connection') ) ); } diff --git a/application/forms/Config/General/LoggingConfigForm.php b/application/forms/Config/General/LoggingConfigForm.php index 759c2a6e3..997bd558a 100644 --- a/application/forms/Config/General/LoggingConfigForm.php +++ b/application/forms/Config/General/LoggingConfigForm.php @@ -4,7 +4,6 @@ namespace Icinga\Forms\Config\General; -use Icinga\Application\Icinga; use Icinga\Application\Logger; use Icinga\Web\Form; use Icinga\Web\Form\Validator\WritablePathValidator; @@ -31,12 +30,12 @@ class LoggingConfigForm extends Form array( 'required' => true, 'autosubmit' => true, - 'label' => t('Logging Type'), - 'description' => t('The type of logging to utilize.'), + 'label' => $this->translate('Logging Type'), + 'description' => $this->translate('The type of logging to utilize.'), 'multiOptions' => array( 'syslog' => 'Syslog', - 'file' => t('File', 'app.config.logging.type'), - 'none' => t('None', 'app.config.logging.type') + 'file' => $this->translate('File', 'app.config.logging.type'), + 'none' => $this->translate('None', 'app.config.logging.type') ) ) ); @@ -47,13 +46,13 @@ class LoggingConfigForm extends Form 'logging_level', array( 'required' => true, - 'label' => t('Logging Level'), - 'description' => t('The maximum logging level to emit.'), + 'label' => $this->translate('Logging Level'), + 'description' => $this->translate('The maximum logging level to emit.'), 'multiOptions' => array( - Logger::$levels[Logger::ERROR] => t('Error', 'app.config.logging.level'), - Logger::$levels[Logger::WARNING] => t('Warning', 'app.config.logging.level'), - Logger::$levels[Logger::INFO] => t('Information', 'app.config.logging.level'), - Logger::$levels[Logger::DEBUG] => t('Debug', 'app.config.logging.level') + Logger::$levels[Logger::ERROR] => $this->translate('Error', 'app.config.logging.level'), + Logger::$levels[Logger::WARNING] => $this->translate('Warning', 'app.config.logging.level'), + Logger::$levels[Logger::INFO] => $this->translate('Information', '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', array( 'required' => true, - 'label' => t('Application Prefix'), - 'description' => t('The name of the application by which to prefix syslog messages.'), + 'label' => $this->translate('Application Prefix'), + 'description' => $this->translate( + 'The name of the application by which to prefix syslog messages.' + ), 'value' => 'icingaweb2', 'validators' => array( array( @@ -91,8 +92,8 @@ class LoggingConfigForm extends Form // 'logging_facility', // array( // 'required' => true, -// 'label' => t('Facility'), -// 'description' => t('The syslog facility to utilize.'), +// 'label' => $this->translate('Facility'), +// 'description' => $this->translate('The syslog facility to utilize.'), // 'multiOptions' => array( // 'user' => 'LOG_USER' // ) @@ -104,8 +105,8 @@ class LoggingConfigForm extends Form 'logging_file', array( 'required' => true, - 'label' => t('File path'), - 'description' => t('The full path to the log file to write messages to.'), + 'label' => $this->translate('File path'), + 'description' => $this->translate('The full path to the log file to write messages to.'), 'value' => '/var/log/icingaweb2/icingaweb2.log', 'validators' => array(new WritablePathValidator()) ) diff --git a/application/forms/Config/GeneralConfigForm.php b/application/forms/Config/GeneralConfigForm.php index 0d81bb96b..7e3357d7b 100644 --- a/application/forms/Config/GeneralConfigForm.php +++ b/application/forms/Config/GeneralConfigForm.php @@ -20,7 +20,7 @@ class GeneralConfigForm extends ConfigForm public function init() { $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()) { - Notification::success(t('New configuration has successfully been stored')); + Notification::success($this->translate('New configuration has successfully been stored')); } else { return false; } diff --git a/application/forms/Config/Resource/DbResourceForm.php b/application/forms/Config/Resource/DbResourceForm.php index 36e69e9e1..9e4027299 100644 --- a/application/forms/Config/Resource/DbResourceForm.php +++ b/application/forms/Config/Resource/DbResourceForm.php @@ -41,8 +41,8 @@ class DbResourceForm extends Form 'name', array( 'required' => true, - 'label' => t('Resource Name'), - 'description' => t('The unique name of this resource') + 'label' => $this->translate('Resource Name'), + 'description' => $this->translate('The unique name of this resource') ) ); $this->addElement( @@ -50,8 +50,8 @@ class DbResourceForm extends Form 'db', array( 'required' => true, - 'label' => t('Database Type'), - 'description' => t('The type of SQL database'), + 'label' => $this->translate('Database Type'), + 'description' => $this->translate('The type of SQL database'), 'multiOptions' => $dbChoices ) ); @@ -60,8 +60,8 @@ class DbResourceForm extends Form 'host', array ( 'required' => true, - 'label' => t('Host'), - 'description' => t('The hostname of the database'), + 'label' => $this->translate('Host'), + 'description' => $this->translate('The hostname of the database'), 'value' => 'localhost' ) ); @@ -70,8 +70,8 @@ class DbResourceForm extends Form 'port', array( 'required' => true, - 'label' => t('Port'), - 'description' => t('The port to use'), + 'label' => $this->translate('Port'), + 'description' => $this->translate('The port to use'), 'value' => 3306 ) ); @@ -80,8 +80,8 @@ class DbResourceForm extends Form 'dbname', array( 'required' => true, - 'label' => t('Database Name'), - 'description' => t('The name of the database to use') + 'label' => $this->translate('Database Name'), + 'description' => $this->translate('The name of the database to use') ) ); $this->addElement( @@ -89,8 +89,8 @@ class DbResourceForm extends Form 'username', array ( 'required' => true, - 'label' => t('Username'), - 'description' => t('The user name to use for authentication') + 'label' => $this->translate('Username'), + 'description' => $this->translate('The user name to use for authentication') ) ); $this->addElement( @@ -99,8 +99,8 @@ class DbResourceForm extends Form array( 'required' => true, 'renderPassword' => true, - 'label' => t('Password'), - 'description' => t('The password to use for authentication') + 'label' => $this->translate('Password'), + '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->getConnection()->getConnection(); } 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; } diff --git a/application/forms/Config/Resource/FileResourceForm.php b/application/forms/Config/Resource/FileResourceForm.php index 8e2920313..960926114 100644 --- a/application/forms/Config/Resource/FileResourceForm.php +++ b/application/forms/Config/Resource/FileResourceForm.php @@ -30,8 +30,8 @@ class FileResourceForm extends Form 'name', array( 'required' => true, - 'label' => t('Resource Name'), - 'description' => t('The unique name of this resource') + 'label' => $this->translate('Resource Name'), + 'description' => $this->translate('The unique name of this resource') ) ); $this->addElement( @@ -39,8 +39,8 @@ class FileResourceForm extends Form 'filename', array( 'required' => true, - 'label' => t('Filepath'), - 'description' => t('The filename to fetch information from'), + 'label' => $this->translate('Filepath'), + 'description' => $this->translate('The filename to fetch information from'), 'validators' => array(new ReadablePathValidator()) ) ); @@ -49,8 +49,8 @@ class FileResourceForm extends Form 'fields', array( 'required' => true, - 'label' => t('Pattern'), - 'description' => t('The regular expression by which to identify columns') + 'label' => $this->translate('Pattern'), + 'description' => $this->translate('The regular expression by which to identify columns') ) ); diff --git a/application/forms/Config/Resource/LdapResourceForm.php b/application/forms/Config/Resource/LdapResourceForm.php index 6641b96bb..c113e2471 100644 --- a/application/forms/Config/Resource/LdapResourceForm.php +++ b/application/forms/Config/Resource/LdapResourceForm.php @@ -32,8 +32,8 @@ class LdapResourceForm extends Form 'name', array( 'required' => true, - 'label' => t('Resource Name'), - 'description' => t('The unique name of this resource') + 'label' => $this->translate('Resource Name'), + 'description' => $this->translate('The unique name of this resource') ) ); $this->addElement( @@ -41,8 +41,10 @@ class LdapResourceForm extends Form 'hostname', array( 'required' => true, - 'label' => t('Host'), - 'description' => t('The hostname or address of the LDAP server to use for authentication'), + 'label' => $this->translate('Host'), + 'description' => $this->translate( + 'The hostname or address of the LDAP server to use for authentication' + ), 'value' => 'localhost' ) ); @@ -51,8 +53,8 @@ class LdapResourceForm extends Form 'port', array( 'required' => true, - 'label' => t('Port'), - 'description' => t('The port of the LDAP server to use for authentication'), + 'label' => $this->translate('Port'), + 'description' => $this->translate('The port of the LDAP server to use for authentication'), 'value' => 389 ) ); @@ -61,8 +63,10 @@ class LdapResourceForm extends Form 'root_dn', array( 'required' => true, - 'label' => t('Root DN'), - 'description' => t('Only the root and its child nodes will be accessible on this resource.') + 'label' => $this->translate('Root DN'), + 'description' => $this->translate( + 'Only the root and its child nodes will be accessible on this resource.' + ) ) ); $this->addElement( @@ -70,8 +74,8 @@ class LdapResourceForm extends Form 'bind_dn', array( 'required' => true, - 'label' => t('Bind DN'), - 'description' => t('The user dn to use for querying the ldap server') + 'label' => $this->translate('Bind DN'), + 'description' => $this->translate('The user dn to use for querying the ldap server') ) ); $this->addElement( @@ -80,8 +84,8 @@ class LdapResourceForm extends Form array( 'required' => true, 'renderPassword' => true, - 'label' => t('Bind Password'), - 'description' => t('The password to use for querying the ldap server') + 'label' => $this->translate('Bind Password'), + 'description' => $this->translate('The password to use for querying the ldap server') ) ); @@ -119,7 +123,9 @@ class LdapResourceForm extends Form throw new Exception(); } } 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; } diff --git a/application/forms/Config/Resource/LivestatusResourceForm.php b/application/forms/Config/Resource/LivestatusResourceForm.php index 2262cf583..996827228 100644 --- a/application/forms/Config/Resource/LivestatusResourceForm.php +++ b/application/forms/Config/Resource/LivestatusResourceForm.php @@ -33,8 +33,8 @@ class LivestatusResourceForm extends Form 'name', array( 'required' => true, - 'label' => t('Resource Name'), - 'description' => t('The unique name of this resource') + 'label' => $this->translate('Resource Name'), + 'description' => $this->translate('The unique name of this resource') ) ); $this->addElement( @@ -42,8 +42,8 @@ class LivestatusResourceForm extends Form 'socket', array( 'required' => true, - 'label' => t('Socket'), - 'description' => t('The path to your livestatus socket used for querying monitoring data'), + 'label' => $this->translate('Socket'), + 'description' => $this->translate('The path to your livestatus socket used for querying monitoring data'), 'value' => '/var/run/icinga2/cmd/livestatus' ) ); @@ -75,8 +75,10 @@ class LivestatusResourceForm extends Form try { $resource = ResourceFactory::createResource(new ConfigObject($form->getValues())); $resource->connect()->disconnect(); - } catch (Exception $e) { - $form->addError(t('Connectivity validation failed, connection to the given resource not possible.')); + } catch (Exception $_) { + $form->addError( + $this->translate('Connectivity validation failed, connection to the given resource not possible.') + ); return false; } diff --git a/application/forms/Config/ResourceConfigForm.php b/application/forms/Config/ResourceConfigForm.php index e7933c18f..67912142a 100644 --- a/application/forms/Config/ResourceConfigForm.php +++ b/application/forms/Config/ResourceConfigForm.php @@ -22,7 +22,7 @@ class ResourceConfigForm extends ConfigForm public function init() { $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') { return new FileResourceForm(); } 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'] : ''; if (! $name) { - throw new InvalidArgumentException(t('Resource name missing')); + throw new InvalidArgumentException($this->translate('Resource name missing')); } elseif ($this->config->hasSection($name)) { - throw new InvalidArgumentException(t('Resource already exists')); + throw new InvalidArgumentException($this->translate('Resource already exists')); } unset($values['name']); @@ -85,11 +85,11 @@ class ResourceConfigForm extends ConfigForm public function edit($name, array $values) { 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'] : '')) { - throw new InvalidArgumentException(t('New resource name missing')); + throw new InvalidArgumentException($this->translate('New resource name missing')); } 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); @@ -111,9 +111,9 @@ class ResourceConfigForm extends ConfigForm public function remove($name) { if (! $name) { - throw new InvalidArgumentException(t('Resource name missing')); + throw new InvalidArgumentException($this->translate('Resource name missing')); } 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); @@ -143,10 +143,10 @@ class ResourceConfigForm extends ConfigForm try { if ($resource === null) { // create new resource $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 $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) { Notification::error($e->getMessage()); @@ -172,9 +172,9 @@ class ResourceConfigForm extends ConfigForm $resource = $this->request->getQuery('resource'); if ($resource !== null) { if ($resource === '') { - throw new ConfigurationError(t('Resource name missing')); + throw new ConfigurationError($this->translate('Resource name missing')); } 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(); @@ -197,8 +197,8 @@ class ResourceConfigForm extends ConfigForm array( 'order' => 0, 'ignore' => true, - 'label' => t('Force Changes'), - 'description' => t('Check this box to enforce changes without connectivity validation') + 'label' => $this->translate('Force Changes'), + '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'; $resourceTypes = array( - 'file' => t('File'), + 'file' => $this->translate('File'), 'livestatus' => 'Livestatus', ); if ($resourceType === 'ldap' || Platform::extensionLoaded('ldap')) { $resourceTypes['ldap'] = 'LDAP'; } if ($resourceType === 'db' || Platform::hasMysqlSupport() || Platform::hasPostgresqlSupport()) { - $resourceTypes['db'] = t('SQL Database'); + $resourceTypes['db'] = $this->translate('SQL Database'); } $this->addElement( @@ -227,8 +227,8 @@ class ResourceConfigForm extends ConfigForm array( 'required' => true, 'autosubmit' => true, - 'label' => t('Resource Type'), - 'description' => t('The type of resource'), + 'label' => $this->translate('Resource Type'), + 'description' => $this->translate('The type of resource'), 'multiOptions' => $resourceTypes, 'value' => $resourceType ) diff --git a/application/forms/ConfirmRemovalForm.php b/application/forms/ConfirmRemovalForm.php index 02d7263df..6840db37d 100644 --- a/application/forms/ConfirmRemovalForm.php +++ b/application/forms/ConfirmRemovalForm.php @@ -17,6 +17,6 @@ class ConfirmRemovalForm extends Form public function init() { $this->setName('form_confirm_removal'); - $this->setSubmitLabel(t('Confirm Removal')); + $this->setSubmitLabel($this->translate('Confirm Removal')); } } diff --git a/application/forms/Dashboard/DashletForm.php b/application/forms/Dashboard/DashletForm.php index 6c38ff97e..e58ca8aba 100644 --- a/application/forms/Dashboard/DashletForm.php +++ b/application/forms/Dashboard/DashletForm.php @@ -26,7 +26,7 @@ class DashletForm extends Form { $this->setName('form_dashboard_addurl'); if (! $this->getSubmitLabel()) { - $this->setSubmitLabel(t('Add To Dashboard')); + $this->setSubmitLabel($this->translate('Add To Dashboard')); } $this->setAction(URL::fromRequest()); } @@ -66,9 +66,10 @@ class DashletForm extends Form 'url', array( 'required' => true, - 'label' => t('Url'), - 'description' => - t('Enter url being loaded in the dashlet. You can paste the full URL, including filters.') + 'label' => $this->translate('Url'), + 'description' => $this->translate( + 'Enter url being loaded in the dashlet. You can paste the full URL, including filters.' + ) ) ); $this->addElement( @@ -76,8 +77,8 @@ class DashletForm extends Form 'dashlet', array( 'required' => true, - 'label' => t('Dashlet Title'), - 'description' => t('Enter a title for the dashlet.') + 'label' => $this->translate('Dashlet Title'), + 'description' => $this->translate('Enter a title for the dashlet.') ) ); $this->addElement( @@ -95,9 +96,8 @@ class DashletForm extends Form 'pane', array( 'required' => true, - 'label' => t("New Dashboard Title"), - 'description' => - t('Enter a title for the new pane.') + 'label' => $this->translate("New Dashboard Title"), + 'description' => $this->translate('Enter a title for the new pane.') ) ); } else { @@ -106,10 +106,9 @@ class DashletForm extends Form 'pane', array( 'required' => true, - 'label' => t('Dashboard'), + 'label' => $this->translate('Dashboard'), 'multiOptions' => $panes, - 'description' => - t('Select a pane you want to add the dashlet.') + 'description' => $this->translate('Select a pane you want to add the dashlet.') ) ); } @@ -119,9 +118,9 @@ class DashletForm extends Form 'create_new_pane', array( 'required' => false, - 'label' => t('New dashboard'), + 'label' => $this->translate('New dashboard'), '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') ) ); } diff --git a/application/forms/LdapDiscoveryForm.php b/application/forms/LdapDiscoveryForm.php index 0fd0ea0d3..ea5f3a99e 100644 --- a/application/forms/LdapDiscoveryForm.php +++ b/application/forms/LdapDiscoveryForm.php @@ -26,8 +26,8 @@ class LdapDiscoveryForm extends Form 'domain', array( 'required' => true, - 'label' => t('Search Domain'), - 'description' => t('Search this domain for records of available servers.'), + 'label' => $this->translate('Search Domain'), + 'description' => $this->translate('Search this domain for records of available servers.'), ) ); @@ -36,7 +36,7 @@ class LdapDiscoveryForm extends Form 'note', 'additional_description', 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 ' . 'configure the server manually.' ) @@ -47,8 +47,8 @@ class LdapDiscoveryForm extends Form 'hostname', array( 'required' => false, - 'label' => t('Host'), - 'description' => t('IP or host name to search.'), + 'label' => $this->translate('Host'), + 'description' => $this->translate('IP or host name to search.'), ) ); @@ -57,8 +57,8 @@ class LdapDiscoveryForm extends Form 'port', array( 'required' => false, - 'label' => t('Port'), - 'description' => t('Port', 389), + 'label' => $this->translate('Port'), + 'description' => $this->translate('Port', 389), ) ); } diff --git a/application/forms/PreferenceForm.php b/application/forms/PreferenceForm.php index e3cfdf319..9b5a3ecf8 100644 --- a/application/forms/PreferenceForm.php +++ b/application/forms/PreferenceForm.php @@ -105,9 +105,9 @@ class PreferenceForm extends Form try { if ($this->getElement('btn_submit_preferences')->isChecked()) { $this->save(); - Notification::success(t('Preferences successfully saved')); + Notification::success($this->translate('Preferences successfully saved')); } 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) { Logger::error($e); @@ -142,13 +142,13 @@ class PreferenceForm extends Form public function createElements(array $formData) { $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) { $languages[$language] = $language; } $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) { $tzList[$tz] = $tz; } @@ -158,8 +158,8 @@ class PreferenceForm extends Form 'language', array( 'required' => true, - 'label' => t('Your Current Language'), - 'description' => t('Use the following language to display texts and messages'), + 'label' => $this->translate('Your Current Language'), + 'description' => $this->translate('Use the following language to display texts and messages'), 'multiOptions' => $languages, 'value' => substr(setlocale(LC_ALL, 0), 0, 5) ) @@ -170,8 +170,8 @@ class PreferenceForm extends Form 'timezone', array( 'required' => true, - 'label' => t('Your Current Timezone'), - 'description' => t('Use the following timezone for dates and times'), + 'label' => $this->translate('Your Current Timezone'), + 'description' => $this->translate('Use the following timezone for dates and times'), 'multiOptions' => $tzList, 'value' => $this->getDefaultTimezone() ) @@ -182,7 +182,7 @@ class PreferenceForm extends Form 'show_benchmark', array( 'required' => true, - 'label' => t('Use benchmark') + 'label' => $this->translate('Use benchmark') ) ); @@ -191,7 +191,7 @@ class PreferenceForm extends Form 'btn_submit_preferences', array( 'ignore' => true, - 'label' => t('Save to the Preferences'), + 'label' => $this->translate('Save to the Preferences'), 'decorators' => array( 'ViewHelper', array('HtmlTag', array('tag' => 'div')) @@ -204,7 +204,7 @@ class PreferenceForm extends Form 'btn_submit_session', array( 'ignore' => true, - 'label' => t('Save for the current Session'), + 'label' => $this->translate('Save for the current Session'), 'decorators' => array( 'ViewHelper', array('HtmlTag', array('tag' => 'div')) diff --git a/application/forms/Security/RoleForm.php b/application/forms/Security/RoleForm.php index b27a4ec8b..f32c0cab4 100644 --- a/application/forms/Security/RoleForm.php +++ b/application/forms/Security/RoleForm.php @@ -72,8 +72,8 @@ class RoleForm extends ConfigForm 'name', array( 'required' => true, - 'label' => t('Role Name'), - 'description' => t('The name of the role'), + 'label' => $this->translate('Role Name'), + 'description' => $this->translate('The name of the role'), 'ignore' => true ), ), @@ -81,24 +81,26 @@ class RoleForm extends ConfigForm 'textarea', 'users', array( - 'label' => t('Users'), - 'description' => t('Comma-separated list of users that are assigned to the role') + 'label' => $this->translate('Users'), + 'description' => $this->translate('Comma-separated list of users that are assigned to the role') ), ), array( 'textarea', 'groups', array( - 'label' => t('Groups'), - 'description' => t('Comma-separated list of groups that are assigned to the role') + 'label' => $this->translate('Groups'), + 'description' => $this->translate('Comma-separated list of groups that are assigned to the role') ), ), array( 'multiselect', 'permissions', array( - 'label' => t('Permissions Set'), - 'description' => t('The permissions to grant. You may select more than one permission'), + 'label' => $this->translate('Permissions Set'), + 'description' => $this->translate( + 'The permissions to grant. You may select more than one permission' + ), 'multiOptions' => $this->providedPermissions ) ) @@ -133,7 +135,7 @@ class RoleForm extends ConfigForm } if (! $this->config->hasSection($name)) { 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 )); } @@ -174,7 +176,7 @@ class RoleForm extends ConfigForm } if ($this->config->hasSection($name)) { throw new InvalidArgumentException(sprintf( - t('Can\'t add role \'%s\'. Role already exists'), + $this->translate('Can\'t add role \'%s\'. Role already exists'), $name )); } @@ -200,7 +202,7 @@ class RoleForm extends ConfigForm } if (! $this->config->hasSection($name)) { 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 )); } @@ -233,7 +235,7 @@ class RoleForm extends ConfigForm } else { if (! $this->config->hasSection($name)) { 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 )); }