PHP code example of abedmaatalla / slim-twig-translation
1. Go to this page and download the library: Download abedmaatalla/slim-twig-translation 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/ */
abedmaatalla / slim-twig-translation example snippets
$container['translator'] = function ($c)
{
// Register the English translator 'en'
$translator = new Illuminate\Translation\Translator(new Illuminate\Translation\FileLoader(new Illuminate\Filesystem\Filesystem(), __DIR__ . '/lang'), 'en');
// setLocal for new location
$translator->setLocale('fr');
return $translator;
};
$container['view'] = function ($c)
{
$view = new \Slim\Views\Twig('../resources/views');
// add translator functions to Twig
$view->addExtension(new \abedmaatalla\Slim\Twig\Extension\TranslationExtension($c->translator));
}
bash
$ php composer.phar install