From 8c87a9df13d1452bfc5906218d25bab1b7809435 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 19 Jan 2015 11:07:39 +0100 Subject: [PATCH] Replace t() and mt() with translate() in setup module's forms refs #7551 --- .../application/forms/AdminAccountPage.php | 35 +++++++++---------- .../application/forms/AuthBackendPage.php | 15 ++++---- .../application/forms/AuthenticationPage.php | 13 ++++--- .../forms/DatabaseCreationPage.php | 23 ++++++------ .../application/forms/DbResourcePage.php | 11 +++--- .../application/forms/GeneralConfigPage.php | 5 ++- .../forms/LdapDiscoveryConfirmPage.php | 6 ++-- .../application/forms/LdapDiscoveryPage.php | 13 +++---- .../application/forms/LdapResourcePage.php | 10 +++--- .../application/forms/PreferencesPage.php | 15 ++++---- .../setup/application/forms/WelcomePage.php | 5 ++- 11 files changed, 69 insertions(+), 82 deletions(-) diff --git a/modules/setup/application/forms/AdminAccountPage.php b/modules/setup/application/forms/AdminAccountPage.php index 6ef791d4e..3b2e6ec9f 100644 --- a/modules/setup/application/forms/AdminAccountPage.php +++ b/modules/setup/application/forms/AdminAccountPage.php @@ -74,16 +74,15 @@ class AdminAccountPage extends Form $choices = array(); if ($this->backendConfig['backend'] !== 'db') { - $choices['by_name'] = mt('setup', 'By Name', 'setup.admin'); + $choices['by_name'] = $this->translate('By Name', 'setup.admin'); $this->addElement( 'text', 'by_name', array( 'required' => isset($formData['user_type']) && $formData['user_type'] === 'by_name', 'value' => $this->getUsername(), - 'label' => mt('setup', 'Username'), - 'description' => mt( - 'setup', + 'label' => $this->translate('Username'), + 'description' => $this->translate( 'Define the initial administrative account by providing a username that reflects' . ' a user created later or one that is authenticated using external mechanisms' ) @@ -94,21 +93,20 @@ class AdminAccountPage extends Form if ($this->backendConfig['backend'] === 'db' || $this->backendConfig['backend'] === 'ldap') { $users = $this->fetchUsers(); if (false === empty($users)) { - $choices['existing_user'] = mt('setup', 'Existing User'); + $choices['existing_user'] = $this->translate('Existing User'); $this->addElement( 'select', 'existing_user', array( 'required' => isset($formData['user_type']) && $formData['user_type'] === 'existing_user', - 'label' => mt('setup', 'Username'), + 'label' => $this->translate('Username'), 'description' => sprintf( - mt( - 'setup', + $this->translate( 'Choose a user reported by the %s backend as the initial administrative account', 'setup.admin' ), $this->backendConfig['backend'] === 'db' - ? mt('setup', 'database', 'setup.admin.authbackend') + ? $this->translate('database', 'setup.admin.authbackend') : 'LDAP' ), 'multiOptions' => array_combine($users, $users) @@ -118,16 +116,15 @@ class AdminAccountPage extends Form } if ($this->backendConfig['backend'] === 'db') { - $choices['new_user'] = mt('setup', 'New User'); + $choices['new_user'] = $this->translate('New User'); $required = isset($formData['user_type']) && $formData['user_type'] === 'new_user'; $this->addElement( 'text', 'new_user', array( 'required' => $required, - 'label' => mt('setup', 'Username'), - 'description' => mt( - 'setup', + 'label' => $this->translate('Username'), + 'description' => $this->translate( 'Enter the username to be used when creating an initial administrative account' ) ) @@ -137,8 +134,8 @@ class AdminAccountPage extends Form 'new_user_password', array( 'required' => $required, - 'label' => mt('setup', 'Password'), - 'description' => mt('setup', 'Enter the password to assign to the newly created account') + 'label' => $this->translate('Password'), + 'description' => $this->translate('Enter the password to assign to the newly created account') ) ); $this->addElement( @@ -146,8 +143,8 @@ class AdminAccountPage extends Form 'new_user_2ndpass', array( 'required' => $required, - 'label' => mt('setup', 'Repeat password'), - 'description' => mt('setup', 'Please repeat the password given above to avoid typing errors'), + 'label' => $this->translate('Repeat password'), + 'description' => $this->translate('Please repeat the password given above to avoid typing errors'), 'validators' => array( array('identical', false, array('new_user_password')) ) @@ -179,7 +176,7 @@ class AdminAccountPage extends Form 'note', 'title', array( - 'value' => mt('setup', 'Administration', 'setup.page.title'), + 'value' => $this->translate('Administration', 'setup.page.title'), 'decorators' => array( 'ViewHelper', array('HtmlTag', array('tag' => 'h2')) @@ -215,7 +212,7 @@ class AdminAccountPage extends Form } if ($data['user_type'] === 'new_user' && array_search($data['new_user'], $this->fetchUsers()) !== false) { - $this->getElement('new_user')->addError(mt('setup', 'Username already exists.')); + $this->getElement('new_user')->addError($this->translate('Username already exists.')); return false; } diff --git a/modules/setup/application/forms/AuthBackendPage.php b/modules/setup/application/forms/AuthBackendPage.php index bd820d352..ced0d9c59 100644 --- a/modules/setup/application/forms/AuthBackendPage.php +++ b/modules/setup/application/forms/AuthBackendPage.php @@ -62,7 +62,7 @@ class AuthBackendPage extends Form 'note', 'title', array( - 'value' => mt('setup', 'Authentication Backend', 'setup.page.title'), + 'value' => $this->translate('Authentication Backend', 'setup.page.title'), 'decorators' => array( 'ViewHelper', array('HtmlTag', array('tag' => 'h2')) @@ -71,20 +71,17 @@ class AuthBackendPage extends Form ); if ($this->config['type'] === 'db') { - $note = mt( - 'setup', + $note = $this->translate( 'As you\'ve chosen to use a database for authentication all you need ' . 'to do now is defining a name for your first authentication backend.' ); } elseif ($this->config['type'] === 'ldap') { - $note = mt( - 'setup', + $note = $this->translate( 'Before you are able to authenticate using the LDAP connection defined earlier you need to' . ' provide some more information so that Icinga Web 2 is able to locate account details.' ); } else { // if ($this->config['type'] === 'autologin' - $note = mt( - 'setup', + $note = $this->translate( 'You\'ve chosen to authenticate using a web server\'s mechanism so it may be necessary' . ' to adjust usernames before any permissions, restrictions, etc. are being applied.' ); @@ -150,8 +147,8 @@ class AuthBackendPage extends Form 'order' => 2, 'ignore' => true, 'required' => true, - 'label' => mt('setup', 'Skip Validation'), - 'description' => mt('setup', 'Check this to not to validate authentication using this backend') + 'label' => $this->translate('Skip Validation'), + 'description' => $this->translate('Check this to not to validate authentication using this backend') ) ); } diff --git a/modules/setup/application/forms/AuthenticationPage.php b/modules/setup/application/forms/AuthenticationPage.php index 2a579e670..88db9c6d8 100644 --- a/modules/setup/application/forms/AuthenticationPage.php +++ b/modules/setup/application/forms/AuthenticationPage.php @@ -29,7 +29,7 @@ class AuthenticationPage extends Form 'note', 'title', array( - 'value' => mt('setup', 'Authentication', 'setup.page.title'), + 'value' => $this->translate('Authentication', 'setup.page.title'), 'decorators' => array( 'ViewHelper', array('HtmlTag', array('tag' => 'h2')) @@ -40,8 +40,7 @@ class AuthenticationPage extends Form 'note', 'description', array( - 'value' => mt( - 'setup', + 'value' => $this->translate( 'Please choose how you want to authenticate when accessing Icinga Web 2.' . ' Configuring backend specific details follows in a later step.' ) @@ -50,20 +49,20 @@ class AuthenticationPage extends Form $backendTypes = array(); if (Platform::hasMysqlSupport() || Platform::hasPostgresqlSupport()) { - $backendTypes['db'] = t('Database'); + $backendTypes['db'] = $this->translate('Database'); } if (Platform::extensionLoaded('ldap')) { $backendTypes['ldap'] = 'LDAP'; } - $backendTypes['autologin'] = t('Autologin'); + $backendTypes['autologin'] = $this->translate('Autologin'); $this->addElement( 'select', 'type', array( 'required' => true, - 'label' => mt('setup', 'Authentication Type'), - 'description' => mt('setup', 'The type of authentication to use when accessing Icinga Web 2'), + 'label' => $this->translate('Authentication Type'), + 'description' => $this->translate('The type of authentication to use when accessing Icinga Web 2'), 'multiOptions' => $backendTypes ) ); diff --git a/modules/setup/application/forms/DatabaseCreationPage.php b/modules/setup/application/forms/DatabaseCreationPage.php index ec4a77ee1..be2974a52 100644 --- a/modules/setup/application/forms/DatabaseCreationPage.php +++ b/modules/setup/application/forms/DatabaseCreationPage.php @@ -90,7 +90,7 @@ class DatabaseCreationPage extends Form 'note', 'title', array( - 'value' => mt('setup', 'Database Setup', 'setup.page.title'), + 'value' => $this->translate('Database Setup', 'setup.page.title'), 'decorators' => array( 'ViewHelper', array('HtmlTag', array('tag' => 'h2')) @@ -101,8 +101,7 @@ class DatabaseCreationPage extends Form 'note', 'description', array( - 'value' => mt( - 'setup', + 'value' => $this->translate( 'It seems that either the database you defined earlier does not yet exist and cannot be created' . ' using the provided access credentials or the database does not have the required schema to ' . 'be operated by Icinga Web 2. Please provide appropriate access credentials to solve this.' @@ -116,16 +115,16 @@ class DatabaseCreationPage extends Form 'username', array( 'required' => false === $skipValidation, - 'label' => mt('setup', 'Username'), - 'description' => mt('setup', 'A user which is able to create databases and/or touch the database schema') + 'label' => $this->translate('Username'), + 'description' => $this->translate('A user which is able to create databases and/or touch the database schema') ) ); $this->addElement( 'password', 'password', array( - 'label' => mt('setup', 'Password'), - 'description' => mt('setup', 'The password for the database user defined above') + 'label' => $this->translate('Password'), + 'description' => $this->translate('The password for the database user defined above') ) ); @@ -182,7 +181,7 @@ class DatabaseCreationPage extends Form // form need to be granted to create databases, users... if (false === $db->checkPrivileges($this->databaseSetupPrivileges)) { $this->addError( - mt('setup', 'The provided credentials cannot be used to create the database and/or the user.') + $this->translate('The provided credentials cannot be used to create the database and/or the user.') ); $this->addSkipValidationCheckbox(); return false; @@ -191,8 +190,7 @@ class DatabaseCreationPage extends Form // ...and to grant all required usage privileges to others if (false === $db->isGrantable($this->databaseUsagePrivileges)) { $this->addError(sprintf( - mt( - 'setup', + $this->translate( 'The provided credentials cannot be used to grant all required privileges to the login "%s".' ), $this->config['username'] @@ -215,9 +213,8 @@ class DatabaseCreationPage extends Form array( 'order' => 2, 'required' => true, - 'label' => mt('setup', 'Skip Validation'), - 'description' => mt( - 'setup', + 'label' => $this->translate('Skip Validation'), + 'description' => $this->translate( 'Check this to not to validate the ability to login and required privileges' ) ) diff --git a/modules/setup/application/forms/DbResourcePage.php b/modules/setup/application/forms/DbResourcePage.php index 4a6535324..1901d8ca9 100644 --- a/modules/setup/application/forms/DbResourcePage.php +++ b/modules/setup/application/forms/DbResourcePage.php @@ -39,7 +39,7 @@ class DbResourcePage extends Form 'note', 'title', array( - 'value' => mt('setup', 'Database Resource', 'setup.page.title'), + 'value' => $this->translate('Database Resource', 'setup.page.title'), 'decorators' => array( 'ViewHelper', array('HtmlTag', array('tag' => 'h2')) @@ -50,8 +50,7 @@ class DbResourcePage extends Form 'note', 'description', array( - 'value' => mt( - 'setup', + 'value' => $this->translate( 'Now please configure your database resource. Note that the database itself does not need to' . ' exist at this time as it is going to be created once the wizard is about to be finished.' ) @@ -121,8 +120,10 @@ class DbResourcePage extends Form 'skip_validation', array( 'required' => true, - 'label' => mt('setup', 'Skip Validation'), - 'description' => mt('setup', 'Check this to not to validate connectivity with the given database server') + 'label' => $this->translate('Skip Validation'), + 'description' => $this->translate( + 'Check this to not to validate connectivity with the given database server' + ) ) ); } diff --git a/modules/setup/application/forms/GeneralConfigPage.php b/modules/setup/application/forms/GeneralConfigPage.php index 309c1784d..e0a9d0fab 100644 --- a/modules/setup/application/forms/GeneralConfigPage.php +++ b/modules/setup/application/forms/GeneralConfigPage.php @@ -29,7 +29,7 @@ class GeneralConfigPage extends Form 'note', 'title', array( - 'value' => mt('setup', 'Application Configuration', 'setup.page.title'), + 'value' => $this->translate('Application Configuration', 'setup.page.title'), 'decorators' => array( 'ViewHelper', array('HtmlTag', array('tag' => 'h2')) @@ -40,8 +40,7 @@ class GeneralConfigPage extends Form 'note', 'description', array( - 'value' => mt( - 'setup', + 'value' => $this->translate( 'Now please adjust all application and logging related configuration options to fit your needs.' ) ) diff --git a/modules/setup/application/forms/LdapDiscoveryConfirmPage.php b/modules/setup/application/forms/LdapDiscoveryConfirmPage.php index f76cbee07..66fd39001 100644 --- a/modules/setup/application/forms/LdapDiscoveryConfirmPage.php +++ b/modules/setup/application/forms/LdapDiscoveryConfirmPage.php @@ -82,7 +82,7 @@ EOT; 'note', 'title', array( - 'value' => mt('setup', 'LDAP Discovery Results', 'setup.page.title'), + 'value' => $this->translate('LDAP Discovery Results', 'setup.page.title'), 'decorators' => array( 'ViewHelper', array('HtmlTag', array('tag' => 'h2')) @@ -94,7 +94,7 @@ EOT; 'description', array( 'value' => sprintf( - mt('setup', 'The following directory service has been found on domain "%s":'), + $this->translate('The following directory service has been found on domain "%s":'), $this->config['domain'] ) ) @@ -119,7 +119,7 @@ EOT; 'confirm', array( 'value' => '1', - 'label' => mt('setup', 'Use this configuration?') + 'label' => $this->translate('Use this configuration?') ) ); } diff --git a/modules/setup/application/forms/LdapDiscoveryPage.php b/modules/setup/application/forms/LdapDiscoveryPage.php index 8c61eb379..26b43803b 100644 --- a/modules/setup/application/forms/LdapDiscoveryPage.php +++ b/modules/setup/application/forms/LdapDiscoveryPage.php @@ -36,7 +36,7 @@ class LdapDiscoveryPage extends Form 'note', 'title', array( - 'value' => mt('setup', 'LDAP Discovery', 'setup.page.title'), + 'value' => $this->translate('LDAP Discovery', 'setup.page.title'), 'decorators' => array( 'ViewHelper', array('HtmlTag', array('tag' => 'h2')) @@ -47,8 +47,7 @@ class LdapDiscoveryPage extends Form 'note', 'description', array( - 'value' => mt( - 'setup', + 'value' => $this->translate( 'You can use this page to discover LDAP or ActiveDirectory servers ' . ' for authentication. If you don\' want to execute a discovery, just skip this step.' ) @@ -66,8 +65,8 @@ class LdapDiscoveryPage extends Form 'skip_validation', array( 'required' => true, - 'label' => mt('setup', 'Skip'), - 'description' => mt('setup', 'Do not discover LDAP servers and enter all settings manually.') + 'label' => $this->translate('Skip'), + 'description' => $this->translate('Do not discover LDAP servers and enter all settings manually.') ) ); } @@ -94,7 +93,9 @@ class LdapDiscoveryPage extends Form return true; } } - $this->addError(sprintf(t('Could not find any LDAP servers on the domain "%s".'), $data['domain'])); + $this->addError( + sprintf($this->translate('Could not find any LDAP servers on the domain "%s".'), $data['domain']) + ); return false; } diff --git a/modules/setup/application/forms/LdapResourcePage.php b/modules/setup/application/forms/LdapResourcePage.php index 49bed69c3..f003a7370 100644 --- a/modules/setup/application/forms/LdapResourcePage.php +++ b/modules/setup/application/forms/LdapResourcePage.php @@ -37,7 +37,7 @@ class LdapResourcePage extends Form 'note', 'title', array( - 'value' => mt('setup', 'LDAP Resource', 'setup.page.title'), + 'value' => $this->translate('LDAP Resource', 'setup.page.title'), 'decorators' => array( 'ViewHelper', array('HtmlTag', array('tag' => 'h2')) @@ -48,8 +48,7 @@ class LdapResourcePage extends Form 'note', 'description', array( - 'value' => mt( - 'setup', + 'value' => $this->translate( 'Now please configure your AD/LDAP resource. This will later ' . 'be used to authenticate users logging in to Icinga Web 2.' ) @@ -107,9 +106,8 @@ class LdapResourcePage extends Form 'skip_validation', array( 'required' => true, - 'label' => mt('setup', 'Skip Validation'), - 'description' => mt( - 'setup', + 'label' => $this->translate('Skip Validation'), + 'description' => $this->translate( 'Check this to not to validate connectivity with the given directory service' ) ) diff --git a/modules/setup/application/forms/PreferencesPage.php b/modules/setup/application/forms/PreferencesPage.php index 26fd048e1..07e011ee1 100644 --- a/modules/setup/application/forms/PreferencesPage.php +++ b/modules/setup/application/forms/PreferencesPage.php @@ -30,8 +30,7 @@ class PreferencesPage extends Form $this->getElement('type') ->setValue('db') ->setDescription( - mt( - 'setup', + $this->translate( 'Note that choosing "Database" causes Icinga Web 2 to use the same database as for authentication.' ) ); @@ -47,7 +46,7 @@ class PreferencesPage extends Form 'note', 'title', array( - 'value' => mt('setup', 'Preferences', 'setup.page.title'), + 'value' => $this->translate('Preferences', 'setup.page.title'), 'decorators' => array( 'ViewHelper', array('HtmlTag', array('tag' => 'h2')) @@ -58,23 +57,23 @@ class PreferencesPage extends Form 'note', 'description', array( - 'value' => mt('setup', 'Please choose how Icinga Web 2 should store user preferences.') + 'value' => $this->translate('Please choose how Icinga Web 2 should store user preferences.') ) ); $storageTypes = array(); - $storageTypes['ini'] = t('File System (INI Files)'); + $storageTypes['ini'] = $this->translate('File System (INI Files)'); if (Platform::hasMysqlSupport() || Platform::hasPostgresqlSupport()) { - $storageTypes['db'] = t('Database'); + $storageTypes['db'] = $this->translate('Database'); } - $storageTypes['null'] = t('Don\'t Store Preferences'); + $storageTypes['null'] = $this->translate('Don\'t Store Preferences'); $this->addElement( 'select', 'type', array( 'required' => true, - 'label' => t('User Preference Storage Type'), + 'label' => $this->translate('User Preference Storage Type'), 'multiOptions' => $storageTypes ) ); diff --git a/modules/setup/application/forms/WelcomePage.php b/modules/setup/application/forms/WelcomePage.php index 5da607683..66340ff25 100644 --- a/modules/setup/application/forms/WelcomePage.php +++ b/modules/setup/application/forms/WelcomePage.php @@ -32,9 +32,8 @@ class WelcomePage extends Form 'token', array( 'required' => true, - 'label' => mt('setup', 'Setup Token'), - 'description' => mt( - 'setup', + 'label' => $this->translate('Setup Token'), + 'description' => $this->translate( 'For security reasons we need to ensure that you are permitted to run this wizard.' . ' Please provide a token by following the instructions below.' ),