2011-11-23 75 views
5

我想通过这种方式关闭翻译缓存:关闭翻译缓存

应用程序/配置/ config.yml

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

在缓存中的缓存代码的/ dev/appDevDebugProjectContainer.php应该是:

 

    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; 
    } 

,但我得到遵循代码:

 

    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')); 
    } 

所以翻译资源是空的。要做到这一点

+0

你已经解决了吗?我有同样的问题.. –

+0

不,我们已经将框架改为Silex。 – constXife

回答

-6

一种方法是:

编辑symfony/src/Symfony/Bundle/FrameworkBundle/Translation/Translator.php并添加一个方法:

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

在你AppKernel.php覆盖方法:

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

编辑核心文件不是个好主意。 – CappY

+0

我必须同意其他评论者的评论。在每个作曲家更新你将失去你的改变 –