Author: david
Date: Tue Sep 13 14:29:31 2011
New Revision: 9711

Log:
Sort messages

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

Modified: trunk/lib/task/i18nConsolidateTask.class.php
==============================================================================
--- trunk/lib/task/i18nConsolidateTask.class.php        Tue Sep 13 14:29:14 
2011        (r9710)
+++ trunk/lib/task/i18nConsolidateTask.class.php        Tue Sep 13 14:29:31 
2011        (r9711)
@@ -89,27 +89,40 @@
 
   public function save($consolidated)
   {
-    $units = array();
+    $messages = array();
+    $translates = array();
+
     foreach ($this->i18n->getMessageSource()->read() as $catalogue => 
$translations)
     {
       foreach ($translations as $key => $values)
       {
-        $consolidated->getMessageSource()->append($key);
+        $messages[] = $key;
 
-        if (!isset($units[$key]))
+        // build associative array containing translated values
+        if (!isset($translates[$key]))
         {
-          $units[$key] = $values;
+          $translates[$key] = $values;
         }
       }
     }
 
-    // Save all source keys to consolidated i18n file
+    // Sort and remove duplicates
+    $messages = array_unique($messages);
+    sort($messages);
+
+    // Add sources to XLIFF file
+    foreach ($messages as $message)
+    {
+      $consolidated->getMessageSource()->append($message);
+    }
+
+    // Save all sources to consolidated i18n file
     $consolidated->getMessageSource()->save();
 
     // Now save translated strings
-    foreach ($units as $key => $item)
+    foreach ($translates as $key => $item)
     {
-      // Track source file in comments
+      // Track source file for message in comments
       $comment = $item[2];
       if (isset($this->sourceFile[$key]))
       {

-- 
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