incubator-zeta-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jero...@apache.org
Subject [zeta-commits] svn commit: r1153790 - in /incubator/zetacomponents/trunk/TemplateTranslationTiein: src/visitors/string_extracter.php tests/extracter.php tests/test_files/test_with_comments.ezt
Date Thu, 04 Aug 2011 08:54:20 GMT
Author: jeromer
Date: Thu Aug  4 08:54:19 2011
New Revision: 1153790

URL: http://svn.apache.org/viewvc?rev=1153790&view=rev
Log:
- Fixed #ZETACOMP-2: comments should be supported in Extractor

(Thanks Maxime Thomas)

Added:
    incubator/zetacomponents/trunk/TemplateTranslationTiein/tests/test_files/test_with_comments.ezt
Modified:
    incubator/zetacomponents/trunk/TemplateTranslationTiein/src/visitors/string_extracter.php
    incubator/zetacomponents/trunk/TemplateTranslationTiein/tests/extracter.php

Modified: incubator/zetacomponents/trunk/TemplateTranslationTiein/src/visitors/string_extracter.php
URL: http://svn.apache.org/viewvc/incubator/zetacomponents/trunk/TemplateTranslationTiein/src/visitors/string_extracter.php?rev=1153790&r1=1153789&r2=1153790&view=diff
==============================================================================
--- incubator/zetacomponents/trunk/TemplateTranslationTiein/src/visitors/string_extracter.php
(original)
+++ incubator/zetacomponents/trunk/TemplateTranslationTiein/src/visitors/string_extracter.php
Thu Aug  4 08:54:19 2011
@@ -117,7 +117,7 @@ class ezcTemplateTranslationStringExtrac
     public function visitTranslationTstNode( ezcTemplateTranslationTstNode $node )
     {
         $string = $node->string->accept( $this );
-        $comment = $node->comment ? $node->comment->accept( $this )->value :
null;
+        $comment = $node->comment ? $node->comment->value : null;
         $file = realpath( $node->source->stream );
         $line = $node->string->startCursor->line;
         $column = $node->string->startCursor->column + 1;

Modified: incubator/zetacomponents/trunk/TemplateTranslationTiein/tests/extracter.php
URL: http://svn.apache.org/viewvc/incubator/zetacomponents/trunk/TemplateTranslationTiein/tests/extracter.php?rev=1153790&r1=1153789&r2=1153790&view=diff
==============================================================================
--- incubator/zetacomponents/trunk/TemplateTranslationTiein/tests/extracter.php (original)
+++ incubator/zetacomponents/trunk/TemplateTranslationTiein/tests/extracter.php Thu Aug  4
08:54:19 2011
@@ -110,6 +110,29 @@ class ezcTemplateTranslationExtracterTes
         );
     }
 
+    function testExtracterWithComments()
+    {
+        $file = dirname( __FILE__ ) . '/test_files/test_with_comments.ezt';
+        $source = new ezcTemplateSourceCode( $file, $file );
+        $source->load();
+
+        $parser = new ezcTemplateParser( $source, new ezcTemplate() );
+        $tst = $parser->parseIntoNodeTree();
+
+        $et = new ezcTemplateTranslationStringExtracter( $parser );
+        $eted = $tst->accept( $et );
+
+        $tr = $et->getTranslation();
+
+        self::assertEquals(
+            array( 'foo' ),
+            array_keys( $this->readAttribute( $tr['test'], 'translationMap' ) )
+        );
+
+        $translationMap = $this->readAttribute( $tr['test'], 'translationMap' );
+        self::assertEquals( "some comment", $translationMap['foo']->comment );
+    }
+
     function testUnifyFileName()
     {
         ob_start();

Added: incubator/zetacomponents/trunk/TemplateTranslationTiein/tests/test_files/test_with_comments.ezt
URL: http://svn.apache.org/viewvc/incubator/zetacomponents/trunk/TemplateTranslationTiein/tests/test_files/test_with_comments.ezt?rev=1153790&view=auto
==============================================================================
--- incubator/zetacomponents/trunk/TemplateTranslationTiein/tests/test_files/test_with_comments.ezt
(added)
+++ incubator/zetacomponents/trunk/TemplateTranslationTiein/tests/test_files/test_with_comments.ezt
Thu Aug  4 08:54:19 2011
@@ -0,0 +1,2 @@
+{tr_context "test"}
+{tr "foo" comment "some comment"}



Mime
View raw message