Module: tools Branch: master Commit: a5a9aac761af96eff4a3b6d5d77a1dad94ab1e66 URL: http://source.winehq.org/git/tools.git/?a=commit;h=a5a9aac761af96eff4a3b6d5d...
Author: Paul Vriens Paul.Vriens.Wine@gmail.com Date: Tue Jul 21 17:29:52 2009 +0200
transl: Fix some php warnings while trying to deal with non-existing files.
---
transl/php/lang.php | 85 ++++++++++++++++++++++++++++----------------------- 1 files changed, 47 insertions(+), 38 deletions(-)
diff --git a/transl/php/lang.php b/transl/php/lang.php index 2dfb7c7..5ee2ca8 100644 --- a/transl/php/lang.php +++ b/transl/php/lang.php @@ -4,55 +4,56 @@ include_once("lib.php");
$lang = validate_lang($_REQUEST['lang']);
-$file = fopen("$DATAROOT/langs/$lang", "r"); $transl = array(); $notransl = array(); $partial = array(); -$curr_file = ""; -while ($line = fgets($file, 4096)) + +function parse_file($lang) { - if (preg_match("/FILE ([A-Z]+) (.*) ([0-9]+) ([0-9]+) ([0-9]+)/", $line, $m)) + global $transl, $partial, $notransl; + global $DATAROOT; + if (!file_exists("$DATAROOT/langs/$lang")) + return; + + $file = fopen("$DATAROOT/langs/$lang", "r"); + $curr_file = ""; + while ($line = fgets($file, 4096)) { - $curr_file = $m[2]; - if ($m[1] == "NONE") + if (preg_match("/FILE ([A-Z]+) (.*) ([0-9]+) ([0-9]+) ([0-9]+)/", $line, $m)) { - $notransl[$curr_file] = array($m[3], $m[4], $m[5], 0); - continue; + $curr_file = $m[2]; + if ($m[1] == "NONE") + { + $notransl[$curr_file] = array($m[3], $m[4], $m[5], 0); + continue; + } + + if ($m[4]>0 || $m[5]>0) + { + $partial[$curr_file] = array($m[3], $m[4], $m[5], 0); + continue; + } + + $transl[$curr_file] = array($m[3], $m[4], $m[5], 0); } - - if ($m[4]>0 || $m[5]>0) + if (preg_match(",$curr_file: Warning: ,", $line, $m)) { - $partial[$curr_file] = array($m[3], $m[4], $m[5], 0); - continue; - } - - $transl[$curr_file] = array($m[3], $m[4], $m[5], 0); - } - if (preg_match(",$curr_file: Warning: ,", $line, $m)) - { - if (array_key_exists($curr_file, $transl)) - { - $partial[$curr_file] = $transl[$curr_file]; - unset($transl[$curr_file]); - } + if (array_key_exists($curr_file, $transl)) + { + $partial[$curr_file] = $transl[$curr_file]; + unset($transl[$curr_file]); + }
- if (array_key_exists($curr_file, $partial)) /* should be true - warning for $notransl shouldn't happen */ - $partial[$curr_file][3]++; + if (array_key_exists($curr_file, $partial)) /* should be true - warning for $notransl shouldn't happen */ + $partial[$curr_file][3]++; + } } + fclose($file); + ksort($transl); + ksort($partial); + ksort($notransl); } -fclose($file); -ksort($transl); -ksort($partial); -ksort($notransl); -?> -<html> -<head> - <link rel="stylesheet" href="style.css" type="text/css"/> - <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> - <title><?php echo get_lang_name($lang) ?> language - Wine translations</title> -</head>
-<?php function dump_table($table) { global $lang; @@ -75,13 +76,21 @@ function dump_table($table) } echo "</table>\n"; } - ?> + +<html> +<head> + <link rel="stylesheet" href="style.css" type="text/css"> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> + <title><?php echo get_lang_name($lang) ?> language - Wine translations</title> +</head> + <p><?php dump_menu_root() ?> > <?php dump_menu_lang($lang, FALSE)?> </p> <div class="main"> <h1><?php echo "Language: ".get_lang_name($lang) ?></h1>
<?php +parse_file($lang); $translations = count($partial) + count($transl); if (preg_match("/:00/", $lang) && $translations == 0) {