【发布时间】:2019-04-08 17:06:25
【问题描述】:
使用 symfony 3.4。当我需要在 Controller 中翻译某些内容时,我会执行以下操作:
$this->get('translator')->trans('termsAndConditions'),
当我想根据 http 状态代码翻译显示的错误消息时,如何在 ExceptionController 中执行此操作?来自命名空间Symfony\Bundle\FrameworkBundle\Controller 的控制器具有ControllerTrait 的特征和get() 方法。命名空间Symfony\Bundle\TwigBundle\Controller下的ExceptionController没有实现get()方法。
那么我怎样才能访问翻译器对象呢?
【问题讨论】:
标签: php symfony exception internationalization