Module: tools Branch: master Commit: 9210ef461e6275dc4bac11855c0d867d9ada4561 URL: http://source.winehq.org/git/tools.git/?a=commit;h=9210ef461e6275dc4bac11855...
Author: Mikolaj Zalewski mikolajz@tygrys.dom Date: Tue Feb 19 14:52:20 2008 +0100
add an [ignore-sublang] instead of collapse to show that the sublang code should be ignored
---
php/index.php | 9 +++++---- php/lib.php | 25 +++++++++++++++++++++---- scripts/conf/005:00 | 2 +- scripts/conf/005:01 | 1 - scripts/conf/011:00 | 2 +- scripts/conf/011:01 | 1 - scripts/conf/012:00 | 2 +- scripts/conf/012:01 | 1 - scripts/conf/018:00 | 2 +- scripts/conf/018:01 | 1 - scripts/conf/019:00 | 2 +- scripts/conf/019:01 | 1 - scripts/conf/01b:00 | 2 +- scripts/conf/01b:01 | 1 - scripts/conf/024:00 | 2 +- scripts/conf/024:01 | 1 - scripts/conf/08f:00 | 2 +- scripts/conf/08f:01 | 1 - scripts/ver.pl | 20 +++++++++++++++----- 19 files changed, 49 insertions(+), 29 deletions(-)
diff --git a/php/index.php b/php/index.php index a8c7ce5..05e2693 100644 --- a/php/index.php +++ b/php/index.php @@ -1,5 +1,6 @@ <?php include_once("config.php"); +include_once("lib.php");
$summary = fopen("$DATAROOT/langs/summary", "r"); while ($line = fgets($summary, 1024)) @@ -8,10 +9,10 @@ while ($line = fgets($summary, 1024)) { die("couldn't parse line $line"); } - - $names[$m[1]] = file_get_contents("$DATAROOT/conf/".$m[1]); - if (strpos($names[$m[1]], "[hide]")) + + if (has_lang_flag($m[1], "hide")) continue; + $sum = $m[2]+0; $transl[$m[1]] = $m[3]; $missing[$m[1]] = $m[4]; @@ -62,7 +63,7 @@ for ($i = 0; $i < count($transl); $i++) echo "<td rowspan="$serial" style="text-align: center">$nr"; echo "</td>"; } - echo "<td><a href="lang.php?lang=$langid">".$names[$langid]."</a></td>"; + echo "<td><a href="lang.php?lang=$langid">".get_lang_name($langid)."</a></td>"; printf("<td>%d (%.1f%%)</td>", $value, ($value*100)/$sum); echo "<td>".$missing[$langid]."</td><td>".$errors[$langid]."</td>\n"; draw_bar($value, $errors[$langid], $sum); diff --git a/php/lib.php b/php/lib.php index 3a51a90..1e90fc9 100644 --- a/php/lib.php +++ b/php/lib.php @@ -35,18 +35,35 @@ function validate_id($id) return $id; }
+function get_raw_lang_name($id) +{ + static $lang_cache = array(); + if (empty($lang_cache[$id])) + { + global $DATAROOT; + + $name = file_get_contents("$DATAROOT/conf/$id"); + $lang_cache[$id] = $name; + } + return $lang_cache[$id]; +} + function get_lang_name($id) { - global $DATAROOT; + return preg_replace("/[ignore-sublang]/", "", get_raw_lang_name($id)); +}
- return file_get_contents("$DATAROOT/conf/$id"); +function has_lang_flag($id, $flag) +{ + return is_int(strpos(get_raw_lang_name($id), "[".$flag."]")); }
function is_lang_ignore_sublang($lang) { - if (!preg_match("/([0-9a-f]{3}):00/", $lang, $m)) + return has_lang_flag($lang, "ignore-sublang"); +/* if (!preg_match("/([0-9a-f]{3}):00/", $lang, $m)) return FALSE; - return (get_lang_name($m[1].":01") == "collapse"); + return (get_lang_name($m[1].":01") == "collapse");*/ }
function get_lang_binid($lang) diff --git a/scripts/conf/005:00 b/scripts/conf/005:00 index 15af5de..ba26bf3 100644 --- a/scripts/conf/005:00 +++ b/scripts/conf/005:00 @@ -1 +1 @@ -Czech \ No newline at end of file +Czech[ignore-sublang] \ No newline at end of file diff --git a/scripts/conf/005:01 b/scripts/conf/005:01 deleted file mode 100644 index f55031a..0000000 --- a/scripts/conf/005:01 +++ /dev/null @@ -1 +0,0 @@ -collapse \ No newline at end of file diff --git a/scripts/conf/011:00 b/scripts/conf/011:00 index dc09008..7123dbe 100644 --- a/scripts/conf/011:00 +++ b/scripts/conf/011:00 @@ -1 +1 @@ -Japanese \ No newline at end of file +Japanese[ignore-sublang] \ No newline at end of file diff --git a/scripts/conf/011:01 b/scripts/conf/011:01 deleted file mode 100644 index f55031a..0000000 --- a/scripts/conf/011:01 +++ /dev/null @@ -1 +0,0 @@ -collapse \ No newline at end of file diff --git a/scripts/conf/012:00 b/scripts/conf/012:00 index 3120cac..060827f 100644 --- a/scripts/conf/012:00 +++ b/scripts/conf/012:00 @@ -1 +1 @@ -Korean \ No newline at end of file +Korean[ignore-sublang] \ No newline at end of file diff --git a/scripts/conf/012:01 b/scripts/conf/012:01 deleted file mode 100644 index f55031a..0000000 --- a/scripts/conf/012:01 +++ /dev/null @@ -1 +0,0 @@ -collapse \ No newline at end of file diff --git a/scripts/conf/018:00 b/scripts/conf/018:00 index a6e3586..8258690 100644 --- a/scripts/conf/018:00 +++ b/scripts/conf/018:00 @@ -1 +1 @@ -Romanian \ No newline at end of file +Romanian[ignore-sublang] \ No newline at end of file diff --git a/scripts/conf/018:01 b/scripts/conf/018:01 deleted file mode 100644 index f55031a..0000000 --- a/scripts/conf/018:01 +++ /dev/null @@ -1 +0,0 @@ -collapse \ No newline at end of file diff --git a/scripts/conf/019:00 b/scripts/conf/019:00 index 9814eb5..74ecec6 100644 --- a/scripts/conf/019:00 +++ b/scripts/conf/019:00 @@ -1 +1 @@ -Russian \ No newline at end of file +Russian[ignore-sublang] \ No newline at end of file diff --git a/scripts/conf/019:01 b/scripts/conf/019:01 deleted file mode 100644 index f55031a..0000000 --- a/scripts/conf/019:01 +++ /dev/null @@ -1 +0,0 @@ -collapse \ No newline at end of file diff --git a/scripts/conf/01b:00 b/scripts/conf/01b:00 index 18f74a2..399b1c9 100644 --- a/scripts/conf/01b:00 +++ b/scripts/conf/01b:00 @@ -1 +1 @@ -Slovak \ No newline at end of file +Slovak[ignore-sublang] \ No newline at end of file diff --git a/scripts/conf/01b:01 b/scripts/conf/01b:01 deleted file mode 100644 index f55031a..0000000 --- a/scripts/conf/01b:01 +++ /dev/null @@ -1 +0,0 @@ -collapse \ No newline at end of file diff --git a/scripts/conf/024:00 b/scripts/conf/024:00 index 94a81b9..fde8a50 100644 --- a/scripts/conf/024:00 +++ b/scripts/conf/024:00 @@ -1 +1 @@ -Slovenian \ No newline at end of file +Slovenian[ignore-sublang] \ No newline at end of file diff --git a/scripts/conf/024:01 b/scripts/conf/024:01 deleted file mode 100644 index f55031a..0000000 --- a/scripts/conf/024:01 +++ /dev/null @@ -1 +0,0 @@ -collapse \ No newline at end of file diff --git a/scripts/conf/08f:00 b/scripts/conf/08f:00 index f13fe40..8c90610 100644 --- a/scripts/conf/08f:00 +++ b/scripts/conf/08f:00 @@ -1 +1 @@ -Esperanto \ No newline at end of file +Esperanto[ignore-sublang] \ No newline at end of file diff --git a/scripts/conf/08f:01 b/scripts/conf/08f:01 deleted file mode 100644 index f55031a..0000000 --- a/scripts/conf/08f:01 +++ /dev/null @@ -1 +0,0 @@ -collapse \ No newline at end of file diff --git a/scripts/ver.pl b/scripts/ver.pl index 26ac823..6b62cdb 100755 --- a/scripts/ver.pl +++ b/scripts/ver.pl @@ -48,20 +48,30 @@ sub resource_name2 {
sub collapse { my($name) = shift @_; + $base_name = $name; + $base_name =~ s/:[0-9a-f][0-9a-f]/:00/; if (not exists $tab_should_collapse{$name}) { - open(NAMEFILE, "<conf/$name"); + open(NAMEFILE, "<conf/$base_name"); $content = <NAMEFILE>; - if ($content eq "collapse") { + close(NAMEFILE); + if ($content =~ /[ignore-sublang]/) { $tab_should_collapse{$name} = TRUE; } else { - $tab_should_collapse{$name} = FALSE; + open(NAMEFILE, "<conf/$name"); + $content = <NAMEFILE>; + if ($content eq "collapse") { + $tab_should_collapse{$name} = TRUE; + } else { + $tab_should_collapse{$name} = FALSE; + } + close(NAMEFILE); } - close(NAMEFILE); + }
if ($tab_should_collapse{$name} eq TRUE) { - $name =~ s/:[0-9a-f][0-9a-f]/:00/; + $name = $base_name; } return $name; }