Author: david
Date: Thu Apr 26 16:51:54 2012
New Revision: 11531
Log:
Extract source strings from fixtures yaml files
Modified:
trunk/lib/task/i18n/i18nConsolidateTask.class.php
Modified: trunk/lib/task/i18n/i18nConsolidateTask.class.php
==============================================================================
--- trunk/lib/task/i18n/i18nConsolidateTask.class.php Thu Apr 26 15:34:28
2012 (r11530)
+++ trunk/lib/task/i18n/i18nConsolidateTask.class.php Thu Apr 26 16:51:54
2012 (r11531)
@@ -86,7 +86,9 @@
class sfI18nConsolidatedExtract extends sfI18nApplicationExtract
{
- protected $messageSource = array();
+ protected
+ $messageSource = array(),
+ $sourceFile = array();
public function configure()
{
@@ -162,10 +164,14 @@
));
}
+ // Extract from fixtures
+ $this->extractFromFixtures(sfConfig::get('sf_data_dir').'/fixtures');
+
// Extract plugin strings
$plugins =
sfFinder::type('dir')->maxdepth(0)->not_name('.')->in(sfConfig::get('sf_plugins_dir'));
foreach ($plugins as $plugin)
{
+ // XLIFFs
foreach (sfFinder::type('dir')->maxdepth(0)->in($plugin.'/modules') as
$piModule)
{
$this->extractFromPhpFiles(array(
@@ -174,10 +180,13 @@
$piModule.'/templates',
));
}
- }
- // Extract fixtures
- $this->extractFromFixtures();
+ // fixtures
+ if (file_exists($plugin.'/data/fixtures'))
+ {
+ $this->extractFromFixtures($plugin.'/data/fixtures');
+ }
+ }
}
/**
@@ -215,11 +224,10 @@
*
* @param string $dir The PHP full path name
*/
- protected function extractFromFixtures()
+ protected function extractFromFixtures($dir)
{
// Search for YAML files
- $fixturesDirs =
array_merge(array(sfConfig::get('sf_data_dir').'/fixtures'),
$this->configuration->getPluginSubPaths('/data/fixtures'));
- $files = sfFinder::type('file')->name('*.yml')->in($fixturesDirs);
+ $files = sfFinder::type('file')->name('*.yml')->in($dir);
if (0 == count($files))
{
@@ -235,18 +243,26 @@
$yaml = new sfYaml;
$fixtures = $yaml->load($file);
- var_dump($fixtures);
- die();
-
- $messages = array_merge($messages, $extracted);
+ if (null == $fixtures)
+ {
+ continue;
+ }
- // Track source file for all messages
- foreach ($extracted as $message)
+ // Descend through fixtures hierarchy
+ foreach ($fixtures as $classname => $fixture)
{
- if (!isset($this->sourceFile[$message]))
+ foreach ($fixture as $key => &$columns)
{
- // Link to file in googlecode repository
- $this->sourceFile[$message] =
str_replace(sfConfig::get('sf_web_dir'),
'http://code.google.com/p/qubit-toolkit/source/browse/trunk', $file);
+ foreach ($columns as $column => &$value)
+ {
+ if (is_array($value) && isset($value['en']))
+ {
+ $messages[] = $value['en'];
+
+ // Link to file in googlecode repository
+ $this->sourceFile[$value['en']] =
str_replace(sfConfig::get('sf_web_dir'),
'http://code.google.com/p/qubit-toolkit/source/browse/trunk', $file);
+ }
+ }
}
}
}
--
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.