Loading potx.inc +9 −0 Original line number Diff line number Diff line Loading @@ -1948,6 +1948,15 @@ function _potx_parse_js_string($string) { * Parse a Twig template for translatables. Drupal 8+. */ function _potx_parse_twig_file($code, $file, $save_callback) { // Extract meta tags, and save text in certain ones. $tags = get_meta_tags($file); $tags_to_save = ['help_topic:label']; foreach ($tags as $key => $content) { if (in_array($key, $tags_to_save)) { $save_callback(_potx_format_quoted_string('"' . trim($content) . '"'), POTX_CONTEXT_NONE, $file, 1); } } $twig_lexer = new Twig_Lexer(new Twig_Environment()); try { Loading src/Tests/PotxTest.php +3 −0 Original line number Diff line number Diff line Loading @@ -285,6 +285,9 @@ class PotxMockLanguageManager { $this->assertMsgId('Test string with @multiple_filters'); $this->assertMsgId('Test string with %multiple_filters'); $this->assertMsgID('Meta-data for a help topic title'); $this->assertNoMsgID('Meta-data that should not be translated'); $this->assertPotxErrors([ 'Concatenation error' => t('Uses of the t filter in Twig templates should start with a single literal string, and should not be chained.'), ]); Loading tests/potx_test_8.html.twig +3 −0 Original line number Diff line number Diff line Loading @@ -4,6 +4,9 @@ * A test Twig template for potx. */ #} <meta name="help_topic:label" content="Meta-data for a help topic title"/> <meta name="not_a_label" content="Meta-data that should not be translated"/> <div id="test"> {% if variable %} <span>{{ variable }}</span> Loading Loading
potx.inc +9 −0 Original line number Diff line number Diff line Loading @@ -1948,6 +1948,15 @@ function _potx_parse_js_string($string) { * Parse a Twig template for translatables. Drupal 8+. */ function _potx_parse_twig_file($code, $file, $save_callback) { // Extract meta tags, and save text in certain ones. $tags = get_meta_tags($file); $tags_to_save = ['help_topic:label']; foreach ($tags as $key => $content) { if (in_array($key, $tags_to_save)) { $save_callback(_potx_format_quoted_string('"' . trim($content) . '"'), POTX_CONTEXT_NONE, $file, 1); } } $twig_lexer = new Twig_Lexer(new Twig_Environment()); try { Loading
src/Tests/PotxTest.php +3 −0 Original line number Diff line number Diff line Loading @@ -285,6 +285,9 @@ class PotxMockLanguageManager { $this->assertMsgId('Test string with @multiple_filters'); $this->assertMsgId('Test string with %multiple_filters'); $this->assertMsgID('Meta-data for a help topic title'); $this->assertNoMsgID('Meta-data that should not be translated'); $this->assertPotxErrors([ 'Concatenation error' => t('Uses of the t filter in Twig templates should start with a single literal string, and should not be chained.'), ]); Loading
tests/potx_test_8.html.twig +3 −0 Original line number Diff line number Diff line Loading @@ -4,6 +4,9 @@ * A test Twig template for potx. */ #} <meta name="help_topic:label" content="Meta-data for a help topic title"/> <meta name="not_a_label" content="Meta-data that should not be translated"/> <div id="test"> {% if variable %} <span>{{ variable }}</span> Loading