PHP code example of smmoosavi / php-gettext

1. Go to this page and download the library: Download smmoosavi/php-gettext library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

smmoosavi / php-gettext example snippets


 // test.php
il\gettext\L10n;

$locale = 'fa_IR';
$lang = 'fa';
L10n::init($lang, __DIR__ . "/locale/$locale/LC_MESSAGES/messages.mo");

var_dump(__('Hi'));
var_dump(__('other'));
json
{
    "mmoosavi/php-gettext": "dev-master"
    }
}
bash
$ php composer.phar install

.
├── composer.json
├── composer.lock
├── locale
│   ├── en_US
│   │   └── LC_MESSAGES
│   │       ├── messages.mo
│   │       └── messages.po
│   └── fa_IR
│       └── LC_MESSAGES
│           ├── messages.mo
│           └── messages.po
├── test.php
└── vendor
    ├── autoload.php
    ...