Replace t() and mt() with translate() in setup module's forms

refs #7551
This commit is contained in:
Johannes Meyer 2015-01-19 11:07:39 +01:00
parent 970006838c
commit 8c87a9df13
11 changed files with 69 additions and 82 deletions

View File

@ -74,16 +74,15 @@ class AdminAccountPage extends Form
$choices = array(); $choices = array();
if ($this->backendConfig['backend'] !== 'db') { 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( $this->addElement(
'text', 'text',
'by_name', 'by_name',
array( array(
'required' => isset($formData['user_type']) && $formData['user_type'] === 'by_name', 'required' => isset($formData['user_type']) && $formData['user_type'] === 'by_name',
'value' => $this->getUsername(), 'value' => $this->getUsername(),
'label' => mt('setup', 'Username'), 'label' => $this->translate('Username'),
'description' => mt( 'description' => $this->translate(
'setup',
'Define the initial administrative account by providing a username that reflects' 'Define the initial administrative account by providing a username that reflects'
. ' a user created later or one that is authenticated using external mechanisms' . ' 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') { if ($this->backendConfig['backend'] === 'db' || $this->backendConfig['backend'] === 'ldap') {
$users = $this->fetchUsers(); $users = $this->fetchUsers();
if (false === empty($users)) { if (false === empty($users)) {
$choices['existing_user'] = mt('setup', 'Existing User'); $choices['existing_user'] = $this->translate('Existing User');
$this->addElement( $this->addElement(
'select', 'select',
'existing_user', 'existing_user',
array( array(
'required' => isset($formData['user_type']) && $formData['user_type'] === 'existing_user', 'required' => isset($formData['user_type']) && $formData['user_type'] === 'existing_user',
'label' => mt('setup', 'Username'), 'label' => $this->translate('Username'),
'description' => sprintf( 'description' => sprintf(
mt( $this->translate(
'setup',
'Choose a user reported by the %s backend as the initial administrative account', 'Choose a user reported by the %s backend as the initial administrative account',
'setup.admin' 'setup.admin'
), ),
$this->backendConfig['backend'] === 'db' $this->backendConfig['backend'] === 'db'
? mt('setup', 'database', 'setup.admin.authbackend') ? $this->translate('database', 'setup.admin.authbackend')
: 'LDAP' : 'LDAP'
), ),
'multiOptions' => array_combine($users, $users) 'multiOptions' => array_combine($users, $users)
@ -118,16 +116,15 @@ class AdminAccountPage extends Form
} }
if ($this->backendConfig['backend'] === 'db') { 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'; $required = isset($formData['user_type']) && $formData['user_type'] === 'new_user';
$this->addElement( $this->addElement(
'text', 'text',
'new_user', 'new_user',
array( array(
'required' => $required, 'required' => $required,
'label' => mt('setup', 'Username'), 'label' => $this->translate('Username'),
'description' => mt( 'description' => $this->translate(
'setup',
'Enter the username to be used when creating an initial administrative account' 'Enter the username to be used when creating an initial administrative account'
) )
) )
@ -137,8 +134,8 @@ class AdminAccountPage extends Form
'new_user_password', 'new_user_password',
array( array(
'required' => $required, 'required' => $required,
'label' => mt('setup', 'Password'), 'label' => $this->translate('Password'),
'description' => mt('setup', 'Enter the password to assign to the newly created account') 'description' => $this->translate('Enter the password to assign to the newly created account')
) )
); );
$this->addElement( $this->addElement(
@ -146,8 +143,8 @@ class AdminAccountPage extends Form
'new_user_2ndpass', 'new_user_2ndpass',
array( array(
'required' => $required, 'required' => $required,
'label' => mt('setup', 'Repeat password'), 'label' => $this->translate('Repeat password'),
'description' => mt('setup', 'Please repeat the password given above to avoid typing errors'), 'description' => $this->translate('Please repeat the password given above to avoid typing errors'),
'validators' => array( 'validators' => array(
array('identical', false, array('new_user_password')) array('identical', false, array('new_user_password'))
) )
@ -179,7 +176,7 @@ class AdminAccountPage extends Form
'note', 'note',
'title', 'title',
array( array(
'value' => mt('setup', 'Administration', 'setup.page.title'), 'value' => $this->translate('Administration', 'setup.page.title'),
'decorators' => array( 'decorators' => array(
'ViewHelper', 'ViewHelper',
array('HtmlTag', array('tag' => 'h2')) 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) { 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; return false;
} }

View File

@ -62,7 +62,7 @@ class AuthBackendPage extends Form
'note', 'note',
'title', 'title',
array( array(
'value' => mt('setup', 'Authentication Backend', 'setup.page.title'), 'value' => $this->translate('Authentication Backend', 'setup.page.title'),
'decorators' => array( 'decorators' => array(
'ViewHelper', 'ViewHelper',
array('HtmlTag', array('tag' => 'h2')) array('HtmlTag', array('tag' => 'h2'))
@ -71,20 +71,17 @@ class AuthBackendPage extends Form
); );
if ($this->config['type'] === 'db') { if ($this->config['type'] === 'db') {
$note = mt( $note = $this->translate(
'setup',
'As you\'ve chosen to use a database for authentication all you need ' '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.' . 'to do now is defining a name for your first authentication backend.'
); );
} elseif ($this->config['type'] === 'ldap') { } elseif ($this->config['type'] === 'ldap') {
$note = mt( $note = $this->translate(
'setup',
'Before you are able to authenticate using the LDAP connection defined earlier you need to' '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.' . ' provide some more information so that Icinga Web 2 is able to locate account details.'
); );
} else { // if ($this->config['type'] === 'autologin' } else { // if ($this->config['type'] === 'autologin'
$note = mt( $note = $this->translate(
'setup',
'You\'ve chosen to authenticate using a web server\'s mechanism so it may be necessary' '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.' . ' to adjust usernames before any permissions, restrictions, etc. are being applied.'
); );
@ -150,8 +147,8 @@ class AuthBackendPage extends Form
'order' => 2, 'order' => 2,
'ignore' => true, 'ignore' => true,
'required' => true, 'required' => true,
'label' => mt('setup', 'Skip Validation'), 'label' => $this->translate('Skip Validation'),
'description' => mt('setup', 'Check this to not to validate authentication using this backend') 'description' => $this->translate('Check this to not to validate authentication using this backend')
) )
); );
} }

View File

@ -29,7 +29,7 @@ class AuthenticationPage extends Form
'note', 'note',
'title', 'title',
array( array(
'value' => mt('setup', 'Authentication', 'setup.page.title'), 'value' => $this->translate('Authentication', 'setup.page.title'),
'decorators' => array( 'decorators' => array(
'ViewHelper', 'ViewHelper',
array('HtmlTag', array('tag' => 'h2')) array('HtmlTag', array('tag' => 'h2'))
@ -40,8 +40,7 @@ class AuthenticationPage extends Form
'note', 'note',
'description', 'description',
array( array(
'value' => mt( 'value' => $this->translate(
'setup',
'Please choose how you want to authenticate when accessing Icinga Web 2.' 'Please choose how you want to authenticate when accessing Icinga Web 2.'
. ' Configuring backend specific details follows in a later step.' . ' Configuring backend specific details follows in a later step.'
) )
@ -50,20 +49,20 @@ class AuthenticationPage extends Form
$backendTypes = array(); $backendTypes = array();
if (Platform::hasMysqlSupport() || Platform::hasPostgresqlSupport()) { if (Platform::hasMysqlSupport() || Platform::hasPostgresqlSupport()) {
$backendTypes['db'] = t('Database'); $backendTypes['db'] = $this->translate('Database');
} }
if (Platform::extensionLoaded('ldap')) { if (Platform::extensionLoaded('ldap')) {
$backendTypes['ldap'] = 'LDAP'; $backendTypes['ldap'] = 'LDAP';
} }
$backendTypes['autologin'] = t('Autologin'); $backendTypes['autologin'] = $this->translate('Autologin');
$this->addElement( $this->addElement(
'select', 'select',
'type', 'type',
array( array(
'required' => true, 'required' => true,
'label' => mt('setup', 'Authentication Type'), 'label' => $this->translate('Authentication Type'),
'description' => mt('setup', 'The type of authentication to use when accessing Icinga Web 2'), 'description' => $this->translate('The type of authentication to use when accessing Icinga Web 2'),
'multiOptions' => $backendTypes 'multiOptions' => $backendTypes
) )
); );

View File

@ -90,7 +90,7 @@ class DatabaseCreationPage extends Form
'note', 'note',
'title', 'title',
array( array(
'value' => mt('setup', 'Database Setup', 'setup.page.title'), 'value' => $this->translate('Database Setup', 'setup.page.title'),
'decorators' => array( 'decorators' => array(
'ViewHelper', 'ViewHelper',
array('HtmlTag', array('tag' => 'h2')) array('HtmlTag', array('tag' => 'h2'))
@ -101,8 +101,7 @@ class DatabaseCreationPage extends Form
'note', 'note',
'description', 'description',
array( array(
'value' => mt( 'value' => $this->translate(
'setup',
'It seems that either the database you defined earlier does not yet exist and cannot be created' '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 ' . ' 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.' . 'be operated by Icinga Web 2. Please provide appropriate access credentials to solve this.'
@ -116,16 +115,16 @@ class DatabaseCreationPage extends Form
'username', 'username',
array( array(
'required' => false === $skipValidation, 'required' => false === $skipValidation,
'label' => mt('setup', 'Username'), 'label' => $this->translate('Username'),
'description' => mt('setup', 'A user which is able to create databases and/or touch the database schema') 'description' => $this->translate('A user which is able to create databases and/or touch the database schema')
) )
); );
$this->addElement( $this->addElement(
'password', 'password',
'password', 'password',
array( array(
'label' => mt('setup', 'Password'), 'label' => $this->translate('Password'),
'description' => mt('setup', 'The password for the database user defined above') '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... // form need to be granted to create databases, users...
if (false === $db->checkPrivileges($this->databaseSetupPrivileges)) { if (false === $db->checkPrivileges($this->databaseSetupPrivileges)) {
$this->addError( $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(); $this->addSkipValidationCheckbox();
return false; return false;
@ -191,8 +190,7 @@ class DatabaseCreationPage extends Form
// ...and to grant all required usage privileges to others // ...and to grant all required usage privileges to others
if (false === $db->isGrantable($this->databaseUsagePrivileges)) { if (false === $db->isGrantable($this->databaseUsagePrivileges)) {
$this->addError(sprintf( $this->addError(sprintf(
mt( $this->translate(
'setup',
'The provided credentials cannot be used to grant all required privileges to the login "%s".' 'The provided credentials cannot be used to grant all required privileges to the login "%s".'
), ),
$this->config['username'] $this->config['username']
@ -215,9 +213,8 @@ class DatabaseCreationPage extends Form
array( array(
'order' => 2, 'order' => 2,
'required' => true, 'required' => true,
'label' => mt('setup', 'Skip Validation'), 'label' => $this->translate('Skip Validation'),
'description' => mt( 'description' => $this->translate(
'setup',
'Check this to not to validate the ability to login and required privileges' 'Check this to not to validate the ability to login and required privileges'
) )
) )

View File

@ -39,7 +39,7 @@ class DbResourcePage extends Form
'note', 'note',
'title', 'title',
array( array(
'value' => mt('setup', 'Database Resource', 'setup.page.title'), 'value' => $this->translate('Database Resource', 'setup.page.title'),
'decorators' => array( 'decorators' => array(
'ViewHelper', 'ViewHelper',
array('HtmlTag', array('tag' => 'h2')) array('HtmlTag', array('tag' => 'h2'))
@ -50,8 +50,7 @@ class DbResourcePage extends Form
'note', 'note',
'description', 'description',
array( array(
'value' => mt( 'value' => $this->translate(
'setup',
'Now please configure your database resource. Note that the database itself does not need to' '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.' . ' 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', 'skip_validation',
array( array(
'required' => true, 'required' => true,
'label' => mt('setup', 'Skip Validation'), 'label' => $this->translate('Skip Validation'),
'description' => mt('setup', 'Check this to not to validate connectivity with the given database server') 'description' => $this->translate(
'Check this to not to validate connectivity with the given database server'
)
) )
); );
} }

View File

@ -29,7 +29,7 @@ class GeneralConfigPage extends Form
'note', 'note',
'title', 'title',
array( array(
'value' => mt('setup', 'Application Configuration', 'setup.page.title'), 'value' => $this->translate('Application Configuration', 'setup.page.title'),
'decorators' => array( 'decorators' => array(
'ViewHelper', 'ViewHelper',
array('HtmlTag', array('tag' => 'h2')) array('HtmlTag', array('tag' => 'h2'))
@ -40,8 +40,7 @@ class GeneralConfigPage extends Form
'note', 'note',
'description', 'description',
array( array(
'value' => mt( 'value' => $this->translate(
'setup',
'Now please adjust all application and logging related configuration options to fit your needs.' 'Now please adjust all application and logging related configuration options to fit your needs.'
) )
) )

View File

@ -82,7 +82,7 @@ EOT;
'note', 'note',
'title', 'title',
array( array(
'value' => mt('setup', 'LDAP Discovery Results', 'setup.page.title'), 'value' => $this->translate('LDAP Discovery Results', 'setup.page.title'),
'decorators' => array( 'decorators' => array(
'ViewHelper', 'ViewHelper',
array('HtmlTag', array('tag' => 'h2')) array('HtmlTag', array('tag' => 'h2'))
@ -94,7 +94,7 @@ EOT;
'description', 'description',
array( array(
'value' => sprintf( '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'] $this->config['domain']
) )
) )
@ -119,7 +119,7 @@ EOT;
'confirm', 'confirm',
array( array(
'value' => '1', 'value' => '1',
'label' => mt('setup', 'Use this configuration?') 'label' => $this->translate('Use this configuration?')
) )
); );
} }

View File

@ -36,7 +36,7 @@ class LdapDiscoveryPage extends Form
'note', 'note',
'title', 'title',
array( array(
'value' => mt('setup', 'LDAP Discovery', 'setup.page.title'), 'value' => $this->translate('LDAP Discovery', 'setup.page.title'),
'decorators' => array( 'decorators' => array(
'ViewHelper', 'ViewHelper',
array('HtmlTag', array('tag' => 'h2')) array('HtmlTag', array('tag' => 'h2'))
@ -47,8 +47,7 @@ class LdapDiscoveryPage extends Form
'note', 'note',
'description', 'description',
array( array(
'value' => mt( 'value' => $this->translate(
'setup',
'You can use this page to discover LDAP or ActiveDirectory servers ' . '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.' ' for authentication. If you don\' want to execute a discovery, just skip this step.'
) )
@ -66,8 +65,8 @@ class LdapDiscoveryPage extends Form
'skip_validation', 'skip_validation',
array( array(
'required' => true, 'required' => true,
'label' => mt('setup', 'Skip'), 'label' => $this->translate('Skip'),
'description' => mt('setup', 'Do not discover LDAP servers and enter all settings manually.') 'description' => $this->translate('Do not discover LDAP servers and enter all settings manually.')
) )
); );
} }
@ -94,7 +93,9 @@ class LdapDiscoveryPage extends Form
return true; 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; return false;
} }

View File

@ -37,7 +37,7 @@ class LdapResourcePage extends Form
'note', 'note',
'title', 'title',
array( array(
'value' => mt('setup', 'LDAP Resource', 'setup.page.title'), 'value' => $this->translate('LDAP Resource', 'setup.page.title'),
'decorators' => array( 'decorators' => array(
'ViewHelper', 'ViewHelper',
array('HtmlTag', array('tag' => 'h2')) array('HtmlTag', array('tag' => 'h2'))
@ -48,8 +48,7 @@ class LdapResourcePage extends Form
'note', 'note',
'description', 'description',
array( array(
'value' => mt( 'value' => $this->translate(
'setup',
'Now please configure your AD/LDAP resource. This will later ' 'Now please configure your AD/LDAP resource. This will later '
. 'be used to authenticate users logging in to Icinga Web 2.' . 'be used to authenticate users logging in to Icinga Web 2.'
) )
@ -107,9 +106,8 @@ class LdapResourcePage extends Form
'skip_validation', 'skip_validation',
array( array(
'required' => true, 'required' => true,
'label' => mt('setup', 'Skip Validation'), 'label' => $this->translate('Skip Validation'),
'description' => mt( 'description' => $this->translate(
'setup',
'Check this to not to validate connectivity with the given directory service' 'Check this to not to validate connectivity with the given directory service'
) )
) )

View File

@ -30,8 +30,7 @@ class PreferencesPage extends Form
$this->getElement('type') $this->getElement('type')
->setValue('db') ->setValue('db')
->setDescription( ->setDescription(
mt( $this->translate(
'setup',
'Note that choosing "Database" causes Icinga Web 2 to use the same database as for authentication.' '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', 'note',
'title', 'title',
array( array(
'value' => mt('setup', 'Preferences', 'setup.page.title'), 'value' => $this->translate('Preferences', 'setup.page.title'),
'decorators' => array( 'decorators' => array(
'ViewHelper', 'ViewHelper',
array('HtmlTag', array('tag' => 'h2')) array('HtmlTag', array('tag' => 'h2'))
@ -58,23 +57,23 @@ class PreferencesPage extends Form
'note', 'note',
'description', 'description',
array( 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 = array();
$storageTypes['ini'] = t('File System (INI Files)'); $storageTypes['ini'] = $this->translate('File System (INI Files)');
if (Platform::hasMysqlSupport() || Platform::hasPostgresqlSupport()) { 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( $this->addElement(
'select', 'select',
'type', 'type',
array( array(
'required' => true, 'required' => true,
'label' => t('User Preference Storage Type'), 'label' => $this->translate('User Preference Storage Type'),
'multiOptions' => $storageTypes 'multiOptions' => $storageTypes
) )
); );

View File

@ -32,9 +32,8 @@ class WelcomePage extends Form
'token', 'token',
array( array(
'required' => true, 'required' => true,
'label' => mt('setup', 'Setup Token'), 'label' => $this->translate('Setup Token'),
'description' => mt( 'description' => $this->translate(
'setup',
'For security reasons we need to ensure that you are permitted to run this wizard.' 'For security reasons we need to ensure that you are permitted to run this wizard.'
. ' Please provide a token by following the instructions below.' . ' Please provide a token by following the instructions below.'
), ),