Author: david
Date: Tue Nov 8 16:33:12 2011
New Revision: 10292
Log:
Reorganize code. Start work on YAML write
Modified:
trunk/lib/task/i18nUpdateFixturesTask.class.php
Modified: trunk/lib/task/i18nUpdateFixturesTask.class.php
==============================================================================
--- trunk/lib/task/i18nUpdateFixturesTask.class.php Tue Nov 8 16:08:57
2011 (r10291)
+++ trunk/lib/task/i18nUpdateFixturesTask.class.php Tue Nov 8 16:33:12
2011 (r10292)
@@ -58,6 +58,16 @@
*/
public function execute($arguments = array(), $options = array())
{
+ // Extract translation string from XLIFF files
+ $translations = $this->extractTranslations($arguments, $options);
+
+ var_dump($translations);
+ }
+
+ protected function extractTranslations($arguments = array(), $options =
array())
+ {
+ $translations = array();
+
$this->logSection('i18n', sprintf('Find XLIFF files named "%s"',
$options['filename']));
// Search for xliff files
@@ -71,35 +81,43 @@
}
// Extract translation strings
- $translations = array();
foreach ($files as $file)
{
- if ($currentTranslations = self::extractTranslations($file))
+ $culture = self::getTargetCulture($file);
+ $xliff = new sfMessageSource_XLIFF(substr($file, 0, strrpos('/')));
+
+ if (!($messages = $xliff->loadData($file)))
+ {
+ continue;
+ }
+
+ // Build list of translations, keyed on source value
+ foreach ($messages as $source => $message)
{
- $translations = array_merge_recursive($translations,
$currentTranslations);
+ $translations[$source][$culture] = $message[0];
}
}
+
+ return $translations;
}
- protected static function extractTranslations($file)
+ protected static function writeYamlFiles()
{
- $translations = array();
- $culture = self::getTargetCulture($file);
-
- $xliff = new sfMessageSource_XLIFF(substr($file, 0, strrpos('/')));
+ // 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);
- if (!($messages = $xliff->loadData($file)))
+ if (0 == count($files))
{
+ $this->logSection('i18n', 'Error: Couldn\'t find any fixture files to
write.');
+
return;
}
- // Build list of translations, keyed on source value
- foreach ($messages as $source => $message)
+ // Write translations to YAML files in data/fixtures
+ foreach ($files as $file)
{
- $translations[$source][$culture] = $message[0];
}
-
- return $translations;
}
protected static function getTargetCulture($filename)
--
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.