5
votes

I'm trying turn off translator cache by this way:

app/config/config.yml

    services:
        translator.default:
            class:  %translator.class%
            arguments: [ @service_container, @translator.selector, {}, { cache_dir: null, debug: %kernel.debug% }, @?session ]

The cached code in cache/dev/appDevDebugProjectContainer.php should be:


    protected function getTranslator_DefaultService()
    {
        $this->services['translator.default'] = $instance = new \Symfony\Bundle\FrameworkBundle\Translation\Translator($this, new \Symfony\Component\Translation\MessageSelector(), array('translation.loader.php' => 'php', 'translation.loader.yml' => 'yml', 'translation.loader.xliff' => 'xliff'), array('cache_dir' => NULL, 'debug' => true), $this->get('session'));

        ... resources ...

        return $instance;
    }

But i get followed code:


    protected function getTranslator_DefaultService()
    {
        return $this->services['translator.default'] = new \Symfony\Bundle\FrameworkBundle\Translation\Translator($this, new \Symfony\Component\Translation\MessageSelector(), array('translation.loader.db' => 'db', 'translation.loader.php' => 'php', 'translation.loader.yml' => 'yml', 'translation.loader.xliff' => 'xliff'), array('cache_dir' => NULL, 'debug' => true), $this->get('session'));
    }

So translator resources is empty.

1
Have you solved it? I have the same problem..Maximilian Ruta
Nope, we have changed framework to Silex.constXife

1 Answers

-6
votes

One way to do this is:

Edit symfony/src/Symfony/Bundle/FrameworkBundle/Translation/Translator.php and add a method:

public function setOption($option, $value)
{
    $this->options[$option] = $value;
}

In your AppKernel.php override a method:

public function boot()
{
    parent::boot();
    $this->container->get('translator')->setOption('cache_dir', null);
}