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: r1087963 - in /incubator/zetacomponents/trunk/TemplateTranslationTiein: src/ tests/ tests/test_files/extractor/templates/customtplextension/
Date Sat, 02 Apr 2011 06:37:45 GMT
Author: jeromer
Date: Sat Apr  2 06:37:45 2011
New Revision: 1087963

URL: http://svn.apache.org/viewvc?rev=1087963&view=rev
Log:
- Fixed #ZETACOMP-1: Template file extension is no longer hard coded
# there is a new "-e" argument in runextractor.php
# run runextractor.php --help for more informations

Added:
    incubator/zetacomponents/trunk/TemplateTranslationTiein/tests/test_files/extractor/templates/customtplextension/
    incubator/zetacomponents/trunk/TemplateTranslationTiein/tests/test_files/extractor/templates/customtplextension/output.xml
    incubator/zetacomponents/trunk/TemplateTranslationTiein/tests/test_files/extractor/templates/customtplextension/test.tpl
Modified:
    incubator/zetacomponents/trunk/TemplateTranslationTiein/src/extractor.php
    incubator/zetacomponents/trunk/TemplateTranslationTiein/tests/extracter.php

Modified: incubator/zetacomponents/trunk/TemplateTranslationTiein/src/extractor.php
URL: http://svn.apache.org/viewvc/incubator/zetacomponents/trunk/TemplateTranslationTiein/src/extractor.php?rev=1087963&r1=1087962&r2=1087963&view=diff
==============================================================================
--- incubator/zetacomponents/trunk/TemplateTranslationTiein/src/extractor.php (original)
+++ incubator/zetacomponents/trunk/TemplateTranslationTiein/src/extractor.php Sat Apr  2 06:37:45
2011
@@ -189,6 +189,22 @@ class ezcTemplateTranslationExtractor
             )
         );
 
+        $this->input->registerOption(
+            new ezcConsoleOption(
+                "e",         // short
+                "extension", // long
+                ezcConsoleInput::TYPE_STRING,
+                'ezt',       // default
+                false,       // multiple
+                'Specifies the file extension for templates',
+                'Specifies the file extension to be used when searching for templates, default
(ezt)',
+                array(),     // dependencies
+                array(),     // exclusions
+                true,        // arguments
+                false        // mandatory
+            )
+        );
+
         $this->input->argumentDefinition = new ezcConsoleArguments();
 
         $this->input->argumentDefinition[0] = new ezcConsoleArgument( "translation
dir" );
@@ -254,7 +270,8 @@ class ezcTemplateTranslationExtractor
         $usedContexts = array();
 
         // find the .ezt files and loop over them.
-        $it = ezcBaseFile::findRecursive( $templatePath, array( '@\.ezt$@' ) );
+        $fileExtension = $this->input->getOption( "extension" )->value;
+        $it = ezcBaseFile::findRecursive( $templatePath, array( "@\.${fileExtension}$@" )
);
         foreach ( $it as $item )
         {
             $pathname = $this->unifyFilepath( realpath( $item ), $templatePath );
@@ -450,4 +467,4 @@ class ezcTemplateTranslationExtractor
         exit( -1 );
     }
 }
-?>
+?>
\ No newline at end of file

Modified: incubator/zetacomponents/trunk/TemplateTranslationTiein/tests/extracter.php
URL: http://svn.apache.org/viewvc/incubator/zetacomponents/trunk/TemplateTranslationTiein/tests/extracter.php?rev=1087963&r1=1087962&r2=1087963&view=diff
==============================================================================
--- incubator/zetacomponents/trunk/TemplateTranslationTiein/tests/extracter.php (original)
+++ incubator/zetacomponents/trunk/TemplateTranslationTiein/tests/extracter.php Sat Apr  2
06:37:45 2011
@@ -154,10 +154,42 @@ class ezcTemplateTranslationExtracterTes
         );
     }
 
+    public function testRunNonEztTemplateExtension()
+    {
+        $origArgv = $_SERVER['argv'];
+        $tmpDir = sys_get_temp_dir();
+        $testFileDir = "TemplateTranslationTiein/tests/test_files/extractor/templates/customtplextension";
+        $tmpFile = "${tmpDir}/en.xml";
+
+        ob_start();
+        $extractor = new ezcTemplateTranslationExtractor();
+
+        $_SERVER['argv'] = array (
+            0 => 'TemplateTranslationTiein/src/runextractor.php',
+            1 => '-t',
+            2 => $testFileDir,
+            3 => '-e',
+            4 => 'tpl',
+            5 => $tmpDir,
+        );
+
+        $extractor->run();
+        ob_end_clean();
+
+        $_SERVER['argv'] = $origArgv;
+
+        $this->assertEquals(
+            file_get_contents( "${testFileDir}/output.xml" ),
+            file_get_contents( $tmpFile )
+        );
+
+        unlink( $tmpFile );
+    }
+
     public static function suite()
     {
          return new PHPUnit_Framework_TestSuite( 'ezcTemplateTranslationExtracterTest' );
     }
 }
 
-?>
+?>
\ No newline at end of file

Added: incubator/zetacomponents/trunk/TemplateTranslationTiein/tests/test_files/extractor/templates/customtplextension/output.xml
URL: http://svn.apache.org/viewvc/incubator/zetacomponents/trunk/TemplateTranslationTiein/tests/test_files/extractor/templates/customtplextension/output.xml?rev=1087963&view=auto
==============================================================================
--- incubator/zetacomponents/trunk/TemplateTranslationTiein/tests/test_files/extractor/templates/customtplextension/output.xml
(added)
+++ incubator/zetacomponents/trunk/TemplateTranslationTiein/tests/test_files/extractor/templates/customtplextension/output.xml
Sat Apr  2 06:37:45 2011
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<TS>
+  <context>
+    <name>admin/forget_password</name>
+    <message>
+      <source>String to translate</source>
+      <translation type="unfinished">String to translate</translation>
+      <location filename="test.tpl" line="2"/>
+    </message>
+  </context>
+</TS>

Added: incubator/zetacomponents/trunk/TemplateTranslationTiein/tests/test_files/extractor/templates/customtplextension/test.tpl
URL: http://svn.apache.org/viewvc/incubator/zetacomponents/trunk/TemplateTranslationTiein/tests/test_files/extractor/templates/customtplextension/test.tpl?rev=1087963&view=auto
==============================================================================
--- incubator/zetacomponents/trunk/TemplateTranslationTiein/tests/test_files/extractor/templates/customtplextension/test.tpl
(added)
+++ incubator/zetacomponents/trunk/TemplateTranslationTiein/tests/test_files/extractor/templates/customtplextension/test.tpl
Sat Apr  2 06:37:45 2011
@@ -0,0 +1,2 @@
+{tr_context "admin/forget_password"}
+{tr "String to translate"}
\ No newline at end of file



Mime
View raw message