소스 검색

[TwigBundle] added the trans filter

Fabien Potencier 14 년 전
부모
커밋
8e654e8f9e
1개의 변경된 파일15개의 추가작업 그리고 0개의 파일을 삭제
  1. 15 0
      src/Symfony/Bundle/TwigBundle/Extension/TransExtension.php

+ 15 - 0
src/Symfony/Bundle/TwigBundle/Extension/TransExtension.php

@@ -33,6 +33,16 @@ class TransExtension extends \Twig_Extension
         return $this->translator;
     }
 
+    /**
+     * {@inheritdoc}
+     */
+    public function getFilters()
+    {
+        return array(
+            'trans' => new \Twig_Filter_Method($this, 'trans'),
+        );
+    }
+
     /**
      * Returns the token parser instance to add to the existing list.
      *
@@ -51,6 +61,11 @@ class TransExtension extends \Twig_Extension
         );
     }
 
+    public function trans($message, array $arguments = array(), $domain = "messages")
+    {
+        return $this->translator->trans($message, $arguments, $domain);
+    }
+
     /**
      * Returns the name of the extension.
      *