<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
phpnomad / symfony-translation-integration example snippets
use PHPNomad\Symfony\Translation\Strategies\TranslationStrategy;
use PHPNomad\Translations\Interfaces\HasLanguage;
use PHPNomad\Translations\Interfaces\HasTextDomain;
use PHPNomad\Translations\Interfaces\TranslationStrategy as TranslationStrategyInterface;
use Symfony\Component\Translation\Loader\ArrayLoader;
use Symfony\Component\Translation\Translator;
use Symfony\Contracts\Translation\TranslatorInterface;
$container->bind(TranslatorInterface::class, function () {
$translator = new Translator('en_US');
$translator->addLoader('array', new ArrayLoader());
$translator->addResource('array', ['hello' => 'Hello'], 'en_US', 'messages');
return $translator;
});
$container->bind(HasTextDomain::class, MyTextDomainProvider::class);
$container->bind(HasLanguage::class, MyLanguageProvider::class);
$container->bind(TranslationStrategyInterface::class, TranslationStrategy::class);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.