diff --git a/core/lib/Drupal/Core/Template/TwigExtension.php b/core/lib/Drupal/Core/Template/TwigExtension.php index ba0f5cd..db5c710 100644 --- a/core/lib/Drupal/Core/Template/TwigExtension.php +++ b/core/lib/Drupal/Core/Template/TwigExtension.php @@ -148,8 +148,8 @@ public function getFunctions() { public function getFilters() { return array( // Translation filters. - new \Twig_SimpleFilter('t', 't', array('is_safe' => array('html'))), - new \Twig_SimpleFilter('trans', 't', array('is_safe' => array('html'))), + new \Twig_SimpleFilter('t', [$this, 't'], array('is_safe' => array('html'))), + new \Twig_SimpleFilter('trans', [$this, 't'], array('is_safe' => array('html'))), // The "raw" filter is not detectable when parsing "trans" tags. To detect // which prefix must be used for translation (@, !, %), we must clone the // "raw" filter and give it identifiable names. These filters should only @@ -177,6 +177,10 @@ public function getFilters() { ); } + public function t(\Twig_Environment $env, $string) { + return new \Twig_Markup(t($string), $env->getCharset()); + } + /** * {@inheritdoc} */ @@ -531,14 +535,14 @@ public function renderVar($arg) { * This value is expected to be safe for output and user provided data * should never be used as a glue. * - * @return string - * The strings joined together. + * @return \Twig_Markup + * The created imploded string, which is now markup. */ public function safeJoin(\Twig_Environment $env, $value, $glue = '') { - return Markup::create(implode($glue, array_map(function($item) use ($env) { + return new \Twig_Markup(implode($glue, array_map(function($item) use ($env) { // If $item is not marked safe then it will be escaped. return $this->escapeFilter($env, $item, 'html', NULL, TRUE); - }, $value))); + }, $value)), $env->getCharset()); } }