License
Codeigniter Gettext is released under GPLv2 license.
Description
This is Codeigniter PHP framework library for dealing with gettext translation and localization.
Instructions
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:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | <?php class Example extends CI_Controller { public function __construct() { parent::__construct(); $this->load->library( 'gettext', array( 'gettext_locale' => 'hr_HR.UTF-8' ) ); } } ?> |
Download
Codeigniter Gettext source code is hosted by GitHub from where you can download current copy of its master branch:
You can also fork or contribute to Codeigniter Gettext by visiting its official GitHub repository page:
Hello,
Can you please write instructions how it is used in views?
If i have .tpl file with content:
Vous ĂȘtes:
what should i insert to make the sentence translated?
Hi Miro,
this library just prepares Codeigniter to use built in translation functionality of PHP:
http://php.net/manual/en/function.gettext.php
So in your case:
echo _(“Vous ĂȘtes:”);
should do the trick but you should have configured langage .po and .mo files inside application/language/locale. Checkout:
https://poeditor.com/help/how_to_translate_gettext_files
for creating .po and .mo files.
Cheers!
Would you please help me?
What is the problem
I have given my debug msg bellow:
———————————————————————
DEBUG - 2016-10-24 03:05:52 --> UTF-8 Support Enabled
DEBUG - 2016-10-24 03:05:52 --> Global POST, GET and COOKIE data sanitized
DEBUG - 2016-10-24 03:05:52 --> Config file loaded: G:\WebProjects\Projects\rpos\application\config/gettext.php
DEBUG - 2016-10-24 03:05:52 --> Try to bind gettext catalog_codeset: UTF-8 - Successful
DEBUG - 2016-10-24 03:05:52 --> Try to bind gettext text domain (locale dir): G:\WebProjects\Projects\rpos/language/ - Successful
DEBUG - 2016-10-24 03:05:52 --> Try to set gettext text_domain: default - Successful
DEBUG - 2016-10-24 03:05:52 --> Try to set gettext locale: bn_BD*** FAILED ***
DEBUG - 2016-10-24 03:05:52 --> Try to set Environment LANGUAGE: bn_BD - Successful
DEBUG - 2016-10-24 03:05:52 --> Total execution time: 0.0496
Screenshot Of my folder structure