Add stuff for testing gettext

This commit is contained in:
Eike Foken
2011-08-10 22:01:21 +02:00
parent 2ea23a7865
commit 92123aa9be
3 changed files with 93 additions and 4 deletions

View File

@@ -7,11 +7,47 @@
*/ */
class MY_Lang extends CI_Lang { class MY_Lang extends CI_Lang {
var $_gettext_language;
var $_gettext_domain;
var $_gettext_path;
/** /**
* Calls the parent constructor. * Calls the parent constructor.
*/ */
public function __construct() { public function __construct() {
parent::__construct(); parent::__construct();
$this->_gettext_domain = 'lang';
log_message('debug', "Gettext Class Initialized");
$this->load_gettext();
}
/**
* This method overides the original load method. It's duty is loading the
* domain files by config or by default internal settings.
*
* @param string $user_lang
*/
public function load_gettext($user_lang = false) {
if ($user_lang) {
$this->_gettext_language = $user_lang;
} else {
$this->_gettext_language = 'en_EN';
}
log_message('debug', 'The gettext language was set by parameter: ' . $this->_gettext_language);
putenv("LANG=$this->_gettext_language");
setlocale(LC_ALL, $this->_gettext_language);
// set the path of .po files
$this->_gettext_path = APPPATH . 'language/locale';
log_message('debug', 'Gettext Class path chosen is: ' . $this->_gettext_path);
bindtextdomain($this->_gettext_domain, $this->_gettext_path);
textdomain($this->_gettext_domain);
log_message('debug', 'The gettext domain chosen is: '. $this->_gettext_domain);
return true;
} }
/** /**

View File

@@ -0,0 +1,53 @@
msgid "users"
msgstr "Users"
msgid "available_users"
msgstr "Available users"
msgid "username"
msgstr "Username"
msgid "realname"
msgstr "Name"
msgid "options"
msgstr "Options"
msgid "user_edit"
msgstr "Edit"
msgid "user_create"
msgstr "Create new user"
msgid "user_delete"
msgstr "Delete"
msgid "create_user"
msgstr "Create a new user"
msgid "edit_user"
msgstr "Edit user"
msgid "field_username"
msgstr "Username"
msgid "field_password"
msgstr "Password"
msgid "field_password_confirm"
msgstr "Confirm password"
msgid "field_firstname"
msgstr "First name"
msgid "field_lastname"
msgstr "Last name"
msgid "field_email"
msgstr "Email address"
msgid "field_institution"
msgstr "Institution"
msgid "field_phone"
msgstr "Phone number"

View File

@@ -3,7 +3,7 @@
<div id="content"> <div id="content">
<div class="title"> <div class="title">
<h2><?=lang('users');?></h2> <h2><?=_('users');?></h2>
</div> </div>
<div class="box"> <div class="box">
@@ -17,15 +17,15 @@
</tr> </tr>
</thead> </thead>
<?php <?php
foreach ($users as $user): foreach ($users as $user):
?> ?>
<tr> <tr>
<td><?=$user['username'];?></td> <td><?=$user['username'];?></td>
<td><?=$user['firstname'];?> <?=$user['lastname'];?></td> <td><?=$user['firstname'];?> <?=$user['lastname'];?></td>
<td><?=anchor('users/edit/' . $user['id'], lang('user_edit'));?> | <a href="javascript:deleteConfirm('<?=site_url('users/delete/' . $user['id']);?>');" title="User"><?=lang('user_delete');?></a></td> <td><?=anchor('users/edit/' . $user['id'], lang('user_edit'));?> | <a href="javascript:deleteConfirm('<?=site_url('users/delete/' . $user['id']);?>');"><?=lang('user_delete');?></a></td>
</tr> </tr>
<?php <?php
endforeach; endforeach;
?> ?>
<tbody> <tbody>
</tbody> </tbody>