From 2899ed81e53f30a209e7dd6acaa3e17947af080b Mon Sep 17 00:00:00 2001 From: Karsten Heiken Date: Thu, 11 Aug 2011 03:49:10 +0200 Subject: [PATCH] Implement gettext for strings inside the controllers --- application/controllers/auth.php | 21 +++++++++++---------- application/controllers/projects.php | 6 +++--- application/controllers/settings.php | 6 +++--- application/controllers/trials.php | 2 +- 4 files changed, 18 insertions(+), 17 deletions(-) diff --git a/application/controllers/auth.php b/application/controllers/auth.php index 27b3f00..500e9f2 100644 --- a/application/controllers/auth.php +++ b/application/controllers/auth.php @@ -37,8 +37,8 @@ class Auth extends CI_Controller { } // validate form input - $this->form_validation->set_rules('username', "Benutzername", 'required'); - $this->form_validation->set_rules('password', "Passwort", 'required'); + $this->form_validation->set_rules('username', _('Username'), 'required'); + $this->form_validation->set_rules('password', _('Password'), 'required'); if ($this->form_validation->run() == true) { // check for "remember me" @@ -77,11 +77,12 @@ class Auth extends CI_Controller { } // validate form input - $this->form_validation->set_rules('username', "Username", 'required'); - $this->form_validation->set_rules('realname', "Realname", 'required'); - $this->form_validation->set_rules('email', "Email address", 'required|valid_email'); - $this->form_validation->set_rules('password', "Password", 'required|min_length[' . $this->config->item('min_password_length', 'access') . ']|max_length[' . $this->config->item('max_password_length', 'access') . ']|matches[password_confirm]'); - $this->form_validation->set_rules('password_confirm', "Password confirmation", 'required'); + $this->form_validation->set_rules('username', _('Username'), 'required'); + $this->form_validation->set_rules('realname', _('Real name'), 'required'); + $this->form_validation->set_rules('lastname', _('Last name'), 'required'); + $this->form_validation->set_rules('email', _('eMail address'), 'required|valid_email'); + $this->form_validation->set_rules('password', _('Password'), 'required|min_length[' . $this->config->item('min_password_length', 'access') . ']|max_length[' . $this->config->item('max_password_length', 'access') . ']|matches[password_confirm]'); + $this->form_validation->set_rules('password_confirm', _('Password confirmation'), 'required'); if ($this->form_validation->run() == true) { $username = $this->input->post('username'); @@ -95,7 +96,7 @@ class Auth extends CI_Controller { if ($this->form_validation->run() == true && $this->access->register($username, $password, $email, $additional_data)) { // redirect them to the login page - $this->session->set_flashdata('message', "Registration successful"); + $this->session->set_flashdata('message', _('Registration successful')); redirect('auth/register_success'); } else { // set the flash data error message if there is one @@ -118,7 +119,7 @@ class Auth extends CI_Controller { } // validate the form - $this->form_validation->set_rules('new_password', 'New Password', 'min_length[' . $this->config->item('min_password_length', 'auth') . ']|max_length[' . $this->config->item('max_password_length', 'access') . ']|matches[new_password_confirm]'); + $this->form_validation->set_rules('new_password', _('New password'), 'min_length[' . $this->config->item('min_password_length', 'auth') . ']|max_length[' . $this->config->item('max_password_length', 'access') . ']|matches[new_password_confirm]'); if ($this->form_validation->run() == true) { // change password if needed @@ -158,7 +159,7 @@ class Auth extends CI_Controller { * Allows users to request a new password. */ public function forgot_password() { - $this->form_validation->set_rules('email', 'Email Address', 'required'); + $this->form_validation->set_rules('email', _('eMail address'), 'required'); if ($this->form_validation->run() == false) { //setup the input $this->data['email'] = array('name' => 'email', diff --git a/application/controllers/projects.php b/application/controllers/projects.php index 4b51387..cd8ef2d 100644 --- a/application/controllers/projects.php +++ b/application/controllers/projects.php @@ -134,7 +134,7 @@ class Projects extends CI_Controller { $this->messages->add($projectpath, 'notice'); redirect('/projects/detail/' . $data['project_id'], 301); } else { - $this->messages->add('Das Projekt konnte nicht gespeichert werden.', 'error'); + $this->messages->add(_('The project could not be created.'), 'error'); $this->load->view('project/new'); } } @@ -148,7 +148,7 @@ class Projects extends CI_Controller { public function detail($prj_id) { $project = $this->project->getById($prj_id); if (!$project) { - $this->messages->add('Das Projekt konnte nicht geladen werden.', 'error'); + $this->messages->add(_('The project could not be loaded.'), 'error'); redirect('projects', 301); } @@ -169,7 +169,7 @@ class Projects extends CI_Controller { public function delete($projectId) { $this->project->delete($projectId); $this->session->unset_userdata('active_project'); - $this->messages->add("Das Projekt wurde gelöscht.", 'notice'); + $this->messages->add(_('The project was deleted.'), 'success'); redirect('projects'); } diff --git a/application/controllers/settings.php b/application/controllers/settings.php index 9348ee3..d694efa 100644 --- a/application/controllers/settings.php +++ b/application/controllers/settings.php @@ -41,9 +41,9 @@ class Settings extends CI_Controller { public function index() { $profile = $this->user->profile(); $profile_fields = array( - array('firstname', 'Vorname', 'text'), - array('lastname', 'Nachname', 'text'), - array('intitution', 'Institution', 'text'), + array('firstname', _('First name'), 'text'), + array('lastname', _('Last name'), 'text'), + array('intitution', _('Institution'), 'text'), ); $tpl['profile'] = $profile; $tpl['profile_fields'] = $profile_fields; diff --git a/application/controllers/trials.php b/application/controllers/trials.php index af8466b..adb1e3a 100644 --- a/application/controllers/trials.php +++ b/application/controllers/trials.php @@ -100,7 +100,7 @@ class Trials extends CI_Controller { redirect('/trial/detail/' . $result, 'refresh'); } else { - $this->messages->add('Der Versuch konnte nicht gespeichert werden.', 'error'); + $this->messages->add(_('The trial could not be created.'), 'error'); $this->load->view('trial/new', $tpl); } }