This library gives users the ability to use gettext more friendly way.
composer require michalsn/codeigniter-gettext
In the example below we will assume, that files from this project will be located in app/ThirdParty/gettext
directory.
Download this project and then enable it by editing the app/Config/Autoload.php
file and adding the Michalsn\CodeIgniterGettext
namespace to the $psr4
array, like in the below example:
<?php
namespace Config;
use CodeIgniter\Config\AutoloadConfig;
class Autoload extends AutoloadConfig
{
// ...
public $psr4 = [
APP_NAMESPACE => APPPATH, // For custom app namespace
'Config' => APPPATH . 'Config',
'Michalsn\CodeIgniterGettext' => APPPATH . 'ThirdParty/gettext/src',
];
// ...
service('gettext')->setLocale('pl');
echo _('Hello');