PHP code example of titon / g11n

1. Go to this page and download the library: Download titon/g11n 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/ */

    

titon / g11n example snippets


use Titon\G11n\Locale;

$g11n = Titon\G11n\G11n:registry();
$g11n->addLocale(new Locale('en'));
$g11n->addLocale(new Locale('fr'));
$g11n->setFallback('en');
$g11n->setTranslator(new Titon\G11n\Translator\MessageTranslator())
    ->setReader(new Titon\Io\Reader\PhpReader())
    ->setStorage(new Titon\Cache\Storage\MemcacheStorage());
$g11n->initialize();

$router->on('g11n', $g11n);

$message = $g11n->translate('domain.catalog.id');
// or
$message = msg('domain.catalog.id');
// or
$message = __('id', 'catalog', 'domain');