Author: david
Date: Tue Nov  8 13:50:32 2011
New Revision: 10289

Log:
Find and read XLIFF files

Modified:
   trunk/lib/task/i18nUpdateFixturesTask.class.php

Modified: trunk/lib/task/i18nUpdateFixturesTask.class.php
==============================================================================
--- trunk/lib/task/i18nUpdateFixturesTask.class.php     Tue Nov  8 13:25:05 
2011        (r10288)
+++ trunk/lib/task/i18nUpdateFixturesTask.class.php     Tue Nov  8 13:50:32 
2011        (r10289)
@@ -41,7 +41,7 @@
       // http://trac.symfony-project.org/ticket/8352
       new sfCommandOption('application', null, 
sfCommandOption::PARAMETER_REQUIRED, 'The application name', true),
       new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 
'The environment', 'cli'),
-      new sfCommandArgument('filename', 'fixtures.xml', 
sfCommandOption::PARAMETER_OPTIONAL, 'Name of xliff files'),
+      new sfCommandOption('filename', 'f', 
sfCommandOption::PARAMETER_OPTIONAL, 'Name of XLIFF files', 'fixtures.xml'),
     ));
 
     $this->namespace = 'i18n';
@@ -58,9 +58,30 @@
    */
   public function execute($arguments = array(), $options = array())
   {
-    $this->logSection('i18n', sprintf('Reading XLIFF files'));
+    $this->logSection('i18n', sprintf('Find XLIFF files named "%s"', 
$options['filename']));
 
-    // Loop through plugins
-    $pluginNames = 
sfFinder::type('dir')->maxdepth(0)->relative()->not_name('.')->in(sfConfig::get('sf_plugins_dir'));
+    // Search for xliff files
+    $files = 
sfFinder::type('file')->name($options['filename'])->in($arguments['path']);
+
+    if (0 == count($files))
+    {
+      $this->logSection('i18n', 'No valid files found.  Please check path and 
filename');
+
+      return;
+    }
+
+    // Extract translation strings
+    $messages = array();
+    foreach ($files as $file)
+    {
+      $xliff = new sfMessageSource_XLIFF(substr($file, 0, strrpos('/')));
+
+      if ($translations = $xliff->loadData($file))
+      {
+        $messages += $translations;
+      }
+    }
+
+    var_dump($messages);
   }
 }

-- 
You received this message because you are subscribed to the Google Groups 
"Qubit Toolkit Commits" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/qubit-commits?hl=en.

Reply via email to