TranslationWriter example

use Symfony\Component\Translation\Writer\TranslationWriter;

class TranslationWriterTest extends TestCase
{
    public function testWrite()
    {
        $dumper = $this->createMock(DumperInterface::class);
        $dumper
            ->expects($this->once())
            ->method('dump');

        $writer = new TranslationWriter();
        $writer->addDumper('test', $dumper);
        $writer->write(new MessageCatalogue('en'), 'test');
    }
}
private function createCommandTester(ProviderInterface $provider, array $locales = ['en'], array $domains = ['messages']$defaultLocale = 'en'): CommandTester
    {
        $command = $this->createCommand($provider$locales$domains$defaultLocale);
        $application = new Application();
        $application->add($command);

        return new CommandTester($application->find('translation:pull'));
    }

    private function createCommand(ProviderInterface $provider, array $locales = ['en'], array $domains = ['messages']$defaultLocale = 'en', array $providerNames = ['loco']): TranslationPullCommand
    {
        $writer = new TranslationWriter();
        $writer->addDumper('xlf', new XliffFileDumper());
        $writer->addDumper('yml', new YamlFileDumper());

        $reader = new TranslationReader();
        $reader->addLoader('xlf', new XliffFileLoader());
        $reader->addLoader('yml', new YamlFileLoader());

        return new TranslationPullCommand(
            $this->getProviderCollection($provider$providerNames$locales$domains),
            $writer,
            $reader,
            
Home | Imprint | This part of the site doesn't use cookies.