Implement gettext for strings inside the controllers

This commit is contained in:
Karsten Heiken
2011-08-11 03:49:10 +02:00
parent 7682bf48c0
commit 2899ed81e5
4 changed files with 18 additions and 17 deletions

View File

@@ -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',

View File

@@ -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');
}

View File

@@ -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;

View File

@@ -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);
}
}