Author: david
Date: Mon Nov 7 09:29:30 2011
New Revision: 10278
Log:
Preserve valid translations from duplicate nodes
Modified:
trunk/lib/task/i18nRemoveDuplicatesTask.class.php
Modified: trunk/lib/task/i18nRemoveDuplicatesTask.class.php
==============================================================================
--- trunk/lib/task/i18nRemoveDuplicatesTask.class.php Mon Nov 7 09:22:28
2011 (r10277)
+++ trunk/lib/task/i18nRemoveDuplicatesTask.class.php Mon Nov 7 09:29:30
2011 (r10278)
@@ -82,20 +82,35 @@
foreach ($xpath->query('//trans-unit') as $unit)
{
+ foreach ($xpath->query('./target', $unit) as $target)
+ {
+ break; // Only one target
+ }
+
foreach ($xpath->query('./source', $unit) as $source)
{
+ // If this is a duplicate source key, then delete it
if (isset($sourceStrings[$source->nodeValue]))
{
+ // If original target string is null, but *this* node has a valid
+ // translation
+ if (0 == strlen($sourceStrings[$source->nodeValue]->nodeValue) &&
+ 0 < strlen($target->nodeValue))
+ {
+ // Copy this translated string to the trans-unit node we are
keeping
+ $sourceStrings[$source->nodeValue]->nodeValue = $target->nodeValue;
+ }
+
// Remove duplicate
$unit->parentNode->removeChild($unit);
$modified = true;
}
else
{
- $sourceStrings[$source->nodeValue] = true;
+ $sourceStrings[$source->nodeValue] = $target;
}
- break;
+ break; // Only one source
}
}
--
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.