codeigniter gettext poedit php |
[eluser]wormhit[/eluser]
Hi! Simple tutorial how to use gettext in your codeigniter application. 1) To translate something use function _('my text') in your controllers and views. 2) Create language files structure as follows: Code: /application/language/locales/lv_LV/LC_MESSAGES/ 3) Configure poedit (http://goo.gl/zSyfz) (use codeigniter paths) and generate *.mo and *.po files using poedit and name them as "lang": Code: result: /application/language/locales/lv_LV/LC_MESSAGES/lang.mo and lang.po 4) Create new codeigniter helper /application/helpers/my_language_helper.php Code: <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); 5) set helper in autoloader: /application/config/autoload.php Code: $autoload['helper'] = array(..., 'my_language'); 6) Initialize translation with function. (You can also set language in cookie and set language in helper) Code: set_translation_language('lv_LV'); That's all! =] I tried to find something like this all over the web, but found nothing. So, I looked at default php gettext functions (http://www.php.net/manual/en/function.gettext.php) and it was so easy to make it work with them. Hopefully that will be useful to someone.. |
Messages In This Thread |
codeigniter gettext poedit php - by El Forum - 06-14-2011, 12:20 PM
codeigniter gettext poedit php - by El Forum - 06-15-2011, 07:48 AM
codeigniter gettext poedit php - by El Forum - 07-17-2011, 11:53 AM
codeigniter gettext poedit php - by El Forum - 07-17-2011, 03:11 PM
codeigniter gettext poedit php - by El Forum - 07-18-2011, 10:26 AM
codeigniter gettext poedit php - by El Forum - 07-18-2011, 12:56 PM
codeigniter gettext poedit php - by El Forum - 07-18-2011, 01:23 PM
codeigniter gettext poedit php - by El Forum - 07-18-2011, 01:31 PM
codeigniter gettext poedit php - by El Forum - 07-22-2012, 08:50 AM
codeigniter gettext poedit php - by El Forum - 08-11-2013, 12:48 PM
codeigniter gettext poedit php - by El Forum - 08-11-2013, 12:56 PM
|