[chrome-gnome-shell/gnome/migration] Sort translations by translated strings



commit 9d129c11b663fd3dc45bc6b6f7dec1c69334b6dc
Author: Yuri Konotopov <ykonotopov gmail com>
Date:   Mon Mar 7 14:32:42 2016 +0300

    Sort translations by translated strings

 contrib/translation-coverage.php |   52 +++++++++++++++++++++++++++-----------
 1 files changed, 37 insertions(+), 15 deletions(-)
---
diff --git a/contrib/translation-coverage.php b/contrib/translation-coverage.php
index 230b675..f1c3e31 100644
--- a/contrib/translation-coverage.php
+++ b/contrib/translation-coverage.php
@@ -107,6 +107,7 @@ if(!$reference_strings)
                        table
                        {
                                width: 700px !important;
+                               margin: 10px auto !important;
                        }
                </style>
        </head>
@@ -124,6 +125,7 @@ if(!$reference_strings)
                        <tbody>
 <?php
 
+$coverage = array();
 foreach($languages as $code => $language)
 {
        if($code == $reference_language)
@@ -154,7 +156,7 @@ foreach($languages as $code => $language)
                }
 
                $missing_count = sizeof($missing);
-               $translated = floor((($reference_count - $missing_count) / $reference_count)  * 100);
+               $translated = (int) floor((($reference_count - $missing_count) / $reference_count)  * 100);
        }
        else
        {
@@ -163,20 +165,40 @@ foreach($languages as $code => $language)
                $missing[] = 'all';
        }
 
-       ?>
-       <tr>
-               <td><?= "$language ($code)" ?></td>
-               <td><?=  "$translated%" ?></td>
-               <td><?= implode(', ', $missing) ?></td>
-               <td><?= implode(', ', $redundant) ?></td>
-               <td>
-                       <div class="graph">
-                               <div class="translated" style="width: <?= $translated ?>px;"></div>
-                               <div class="untranslated" style="left: 100px; width: <?= (100 - $translated) 
?>px;"></div>
-                       </div>
-               </td>
-       </tr>
-       <?php
+       if(!array_key_exists($translated, $coverage))
+       {
+               $coverage[$translated] = array();
+       }
+
+       $coverage[$translated][] = array(
+               'language'      => $language,
+               'code'          => $code,
+               'missing'       => $missing,
+               'redundant'     => $redundant
+       );
+}
+
+krsort($coverage);
+
+foreach($coverage as $translated => $languages)
+{
+       foreach($languages as $data)
+       {
+               ?>
+               <tr>
+                       <td><?= "{$data['language']} ({$data['code']})" ?></td>
+                       <td><?=  "$translated%" ?></td>
+                       <td><?= implode(', ', $data['missing']) ?></td>
+                       <td><?= implode(', ', $data['redundant']) ?></td>
+                       <td>
+                               <div class="graph">
+                                       <div class="translated" style="width: <?= $translated ?>px;"></div>
+                                       <div class="untranslated" style="left: 100px; width: <?= (100 - 
$translated) ?>px;"></div>
+                               </div>
+                       </td>
+               </tr>
+               <?php
+       }
 }
 ?>
        </tbody>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]