This is Codeigniter PHP framework library for dealing with gettext.
Please note that following steps assume that you have correctly installed gettext and configured Codeigniter on your server.
- Place gettext.php inside application/config.
- Place Gettext.php inside application/libraries.
- Adjust application/config/gettext.php with your
$config['gettext_catalog_codeset']
,$config['gettext_text_domain']
,$config['gettext_locale_dir']
and$config['gettext_locale']
. - Create gettext locales directory according to your
$config['gettext_locale_dir']
(application/language/locale by default). Inside that directory create locale_name/LC_MESSAGES path for each of your locales and place your .mo files inside. - Add
'gettext'
to Auto-load Config files array or use$this->config->load('gettext')
inside your controller. - Add
'gettext'
to Auto-load Libraries array or use$this->load->library('gettext')
inside your controller.
If you are loading this library inside your controller you can override any of the default configuration directives. For example if you want to override default $config['gettext_locale']
with hr_HR.UTF-8 you could use something like this:
<?php
class Example extends CI_Controller {
public function __construct() {
parent::__construct();
$this->load->library(
'gettext',
array(
'gettext_locale' => 'hr_HR.UTF-8'
)
);
}
}
?>