Paul Vriens : transl: Get rid of the [hide] parameter in the conf files.

Alexandre Julliard julliard at winehq.org
Thu Jul 16 11:56:56 CDT 2009


Module: tools
Branch: master
Commit: 1bcd58ff30ab1d7cd5bb0416c4d4752d26a5bc78
URL:    http://source.winehq.org/git/tools.git/?a=commit;h=1bcd58ff30ab1d7cd5bb0416c4d4752d26a5bc78

Author: Paul Vriens <paul at acer.famvriens.nl>
Date:   Wed Jul 15 12:38:09 2009 +0200

transl: Get rid of the [hide] parameter in the conf files.

---

 transl/php/index.php       |    2 +-
 transl/php/lang.php        |    9 +++++++-
 transl/php/lib.php         |   50 +++++++++++++++++++++++++++++++++----------
 transl/php/resfile.php     |   10 +++++++-
 transl/php/style.css       |    1 +
 transl/scripts/conf/016:00 |    2 +-
 6 files changed, 57 insertions(+), 17 deletions(-)

diff --git a/transl/php/index.php b/transl/php/index.php
index 76ed5a8..94ee569 100644
--- a/transl/php/index.php
+++ b/transl/php/index.php
@@ -10,7 +10,7 @@ while ($line = fgets($summary, 1024))
         die("couldn't parse line $line");
     }
 
-    if (has_lang_flag($m[1], "hide"))
+    if ($m[3] == 0)
         continue;
     
     $sum = $m[2]+0;
diff --git a/transl/php/lang.php b/transl/php/lang.php
index bb46261..c6a237f 100644
--- a/transl/php/lang.php
+++ b/transl/php/lang.php
@@ -84,7 +84,14 @@ function dump_table($table)
 <div class="main">
 <h1><?php echo "Language: ".get_lang_name($lang) ?></h1>
 
-<?php warn_if_lang_hidden($lang) ?>
+<?php
+$translations = count($partial) + count($transl);
+if (preg_match("/:00/", $lang) && $translations == 0)
+{
+    show_sublangs($lang);
+    exit();
+}
+?>
 
 <div class="group">
 <h2>Partially translated modules</h2>
diff --git a/transl/php/lib.php b/transl/php/lib.php
index adde182..6774775 100644
--- a/transl/php/lib.php
+++ b/transl/php/lib.php
@@ -60,6 +60,44 @@ function get_lang_base($id)
     return preg_replace("/:[0-9a-f]{2}/", ":00", $id);
 }
 
+function get_sublangs($id)
+{
+    if (preg_match("/:00/", $id))
+    {
+        global $LOCALE_NAMES;
+        include_once("dump_locales.php");
+
+        $base = preg_replace("/:00/", "", $id);
+        $sublangs = array();
+        foreach ($LOCALE_NAMES as $key => $value)
+            if (preg_match("/$base/", $key) && ($key != $id))
+                $sublangs[] = $key;
+        return $sublangs;
+    }
+    else
+        return NULL;
+}
+
+function show_sublangs($id)
+{
+    echo "<p class=\"note\"><b>Note:</b> This is the '".get_lang_name($id)."' locale which ".
+         "is not used directly but has resources inherited by sublanguages.<br />".
+         "You can still use this locale in translations but the results will show up at the ".
+         "sublanguages (see below).</p>";
+
+    echo "<div class=\"group\">";
+    echo "<h2>Sublanguages</h2>";
+    echo "<table>\n";
+    echo "<tr><th>Sublanguage</th></tr>\n";
+    $sublangs = get_sublangs($id);
+    foreach ($sublangs as $key)
+    {
+        echo "<tr><td>".gen_lang_a($key).get_lang_name($key)."</a></td></tr>";
+    }
+    echo "</table>\n";
+    echo "</div>";
+}
+
 function has_lang_flag($id, $flag)
 {
     return is_int(strpos(get_raw_lang_name($id), "[".$flag."]"));
@@ -79,18 +117,6 @@ function get_lang_binid($lang)
     return hexdec($m[1]) + (hexdec($m[2]) << 10);
 }
 
-/* Make sure people are not suprised if they see Portugese (Neutral) has nearly
- * no resources */
-function warn_if_lang_hidden($lang)
-{
-    if (has_lang_flag($lang, "hide"))
-    {
-        echo "<p class=\"note\"><b>Note:</b> this is the ".get_lang_name($lang)." locale which\n".
-            "is not supposed to be used directly but only to have some resources\n".
-            "inherited by sublanguages.</p>";
-    }
-}
-
 function get_locale_name($localeid)
 {
     global $LOCALE_NAMES;
diff --git a/transl/php/resfile.php b/transl/php/resfile.php
index 685f80e..337dc89 100644
--- a/transl/php/resfile.php
+++ b/transl/php/resfile.php
@@ -19,7 +19,6 @@ $msgs = array();
 <h1>Module <?php echo $resfile?></h1>
 
 <?php
-warn_if_lang_hidden($lang);
 
 while ($line = fgets($file, 4096))
 {
@@ -29,7 +28,14 @@ while ($line = fgets($file, 4096))
     }
 }
 
-if (count($msgs) == 0) {
+if (count($msgs) == 0)
+{
+    if (preg_match("/:00/", $lang))
+    {
+        show_sublangs($lang);
+        exit();
+    }
+
     echo "<p>This module is not translated into ".get_lang_name($lang).".</p>\n";
     echo "<ul><li>If you want to see what resources are in this module, check the "
             .gen_resfile_a($MASTER_LANGUAGE, $resfile)."English (US) version</a>"
diff --git a/transl/php/style.css b/transl/php/style.css
index e600cc7..0464bc2 100644
--- a/transl/php/style.css
+++ b/transl/php/style.css
@@ -89,6 +89,7 @@ p.note
     border-style: solid;
     border-color: black;
     padding: 2px;
+    text-align: center;
 }
 
 /* table with a standard resource dump */
diff --git a/transl/scripts/conf/016:00 b/transl/scripts/conf/016:00
index 13944f6..edbd93f 100644
--- a/transl/scripts/conf/016:00
+++ b/transl/scripts/conf/016:00
@@ -1 +1 @@
-Portugese (Neutral)[hide]
\ No newline at end of file
+Portuguese (Neutral)




More information about the wine-cvs mailing list