PHP code example of chubbyphp / chubbyphp-translation
1. Go to this page and download the library: Download chubbyphp/chubbyphp-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/ */
chubbyphp / chubbyphp-translation example snippets
use Chubbyphp\Translation\Translator;
use Chubbyphp\Translation\TranslationProvider;
use Pimple\Container;
$container->register(new TranslationProvider);
$container->extend('translator.providers', function (array $providers) use ($container) {
$providers[] = new LocaleTranslationProvider('de', [
'some.existing.key' => 'erfolgreiche Uebersetzung',
'another.existing.key' => '%d erfolgreiche Uebersetzungen'
]);
$providers[] = new LocaleTranslationProvider('en', [
'some.existing.key' => 'successful translation',
'another.existing.key' => '%d successful translations'
]);
return $providers;
});
/** @var Translation $translator */
$translator = $container['translator'];
use Chubbyphp\Translation\LocaleTranslationProvider;
use Chubbyphp\Translation\TranslationTwigExtension;
use Chubbyphp\Translation\Translator;
$twig->addExtension(new TranslationTwigExtension(new Translator([])));