Author: david
Date: Tue Nov 8 16:08:57 2011
New Revision: 10291
Log:
Succesfully reading XLIFF strings, now need to write them to data/fixtures
Modified:
trunk/lib/task/i18nUpdateFixturesTask.class.php
Modified: trunk/lib/task/i18nUpdateFixturesTask.class.php
==============================================================================
--- trunk/lib/task/i18nUpdateFixturesTask.class.php Tue Nov 8 13:51:15
2011 (r10290)
+++ trunk/lib/task/i18nUpdateFixturesTask.class.php Tue Nov 8 16:08:57
2011 (r10291)
@@ -71,17 +71,46 @@
}
// Extract translation strings
- $messages = array();
+ $translations = array();
foreach ($files as $file)
{
- $xliff = new sfMessageSource_XLIFF(substr($file, 0, strrpos('/')));
-
- if ($translations = $xliff->loadData($file))
+ if ($currentTranslations = self::extractTranslations($file))
{
- $messages += $translations;
+ $translations = array_merge_recursive($translations,
$currentTranslations);
}
}
+ }
+
+ protected static function extractTranslations($file)
+ {
+ $translations = array();
+ $culture = self::getTargetCulture($file);
+
+ $xliff = new sfMessageSource_XLIFF(substr($file, 0, strrpos('/')));
+
+ if (!($messages = $xliff->loadData($file)))
+ {
+ return;
+ }
+
+ // Build list of translations, keyed on source value
+ foreach ($messages as $source => $message)
+ {
+ $translations[$source][$culture] = $message[0];
+ }
+
+ return $translations;
+ }
+
+ protected static function getTargetCulture($filename)
+ {
+ libxml_use_internal_errors(true);
+ if (!$xml = simplexml_load_file($filename))
+ {
+ return;
+ }
+ libxml_use_internal_errors(false);
- var_dump($messages);
+ return (string) $xml->file['target-language'];
}
}
--
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.