diff --git a/diff.php b/diff.php index 0e60e71..c6ce0ae 100644 --- a/diff.php +++ b/diff.php @@ -17,208 +17,208 @@ require_once('config.php'); ?> -
-
-
- Please type your language code in ISO 639-1. For example: pl for Polish, de for German -
- -
- " id="lang" name="lang" class="form-control input-md" required="required" autofocus="autofocus" pattern="[A-Za-z]{2}" title="Two letter language code"/> -
+
+ +
+Please type your language code in ISO 639-1. For example: pl for Polish, de for German +
+ +
+ " id="lang" name="lang" class="form-control input-md" required="required" autofocus="autofocus" pattern="[A-Za-z]{2}" title="Two letter language code"/>
-
- -
- -
+
+
+ +
+
-
- -
-
- -
-
+
+
+ +
+
+ +
+
- append(new RecursiveIteratorIterator( $directory1 )); - $it->append(new RecursiveIteratorIterator( $directory2 )); - $it->append(new RecursiveIteratorIterator( $directory3 )); - $it->append(new RecursiveIteratorIterator( $directory4 )); - $it->append(new RecursiveIteratorIterator( $directory5 )); - break; - - case "2": - $directory6 = new RecursiveDirectoryIterator($ROSDir. "dll/cpl"); - $directory7 = new RecursiveDirectoryIterator($ROSDir. "dll/shellext"); - $directory8 = new RecursiveDirectoryIterator($ROSDir. "dll/win32"); - - $it = new AppendIterator(); - $it->append(new RecursiveIteratorIterator( $directory6 )); - $it->append(new RecursiveIteratorIterator( $directory7 )); - $it->append(new RecursiveIteratorIterator( $directory8 )); - break; - - case "3": - $directory9 = new RecursiveDirectoryIterator($ROSDir. "media/themes"); - $directory10 = new RecursiveDirectoryIterator($ROSDir. "subsystems/mvdm/ntvdm"); - $directory11 = new RecursiveDirectoryIterator($ROSDir. "win32ss/user"); - - $it = new AppendIterator(); - $it->append(new RecursiveIteratorIterator( $directory9 )); - $it->append(new RecursiveIteratorIterator( $directory10 )); - $it->append(new RecursiveIteratorIterator( $directory11 )); - break; - - // Search in source dir - only for test - case "100": - $directory1 = new RecursiveDirectoryIterator($ROSDir); - - $it = new AppendIterator(); - $it->append(new RecursiveIteratorIterator( $directory1 )); - break; - - default: - echo "Something is wrong! Please try again."; - exit; - } + case "1": + $directory1 = new RecursiveDirectoryIterator($ROSDir. "base/applications"); + $directory2 = new RecursiveDirectoryIterator($ROSDir. "base/setup"); + $directory3 = new RecursiveDirectoryIterator($ROSDir. "base/shell"); + $directory4 = new RecursiveDirectoryIterator($ROSDir. "base/system"); + $directory5 = new RecursiveDirectoryIterator($ROSDir. "boot/freeldr/fdebug"); + + $it = new AppendIterator(); + $it->append(new RecursiveIteratorIterator( $directory1 )); + $it->append(new RecursiveIteratorIterator( $directory2 )); + $it->append(new RecursiveIteratorIterator( $directory3 )); + $it->append(new RecursiveIteratorIterator( $directory4 )); + $it->append(new RecursiveIteratorIterator( $directory5 )); + break; + + case "2": + $directory6 = new RecursiveDirectoryIterator($ROSDir. "dll/cpl"); + $directory7 = new RecursiveDirectoryIterator($ROSDir. "dll/shellext"); + $directory8 = new RecursiveDirectoryIterator($ROSDir. "dll/win32"); + + $it = new AppendIterator(); + $it->append(new RecursiveIteratorIterator( $directory6 )); + $it->append(new RecursiveIteratorIterator( $directory7 )); + $it->append(new RecursiveIteratorIterator( $directory8 )); + break; + + case "3": + $directory9 = new RecursiveDirectoryIterator($ROSDir. "media/themes"); + $directory10 = new RecursiveDirectoryIterator($ROSDir. "subsystems/mvdm/ntvdm"); + $directory11 = new RecursiveDirectoryIterator($ROSDir. "win32ss/user"); + + $it = new AppendIterator(); + $it->append(new RecursiveIteratorIterator( $directory9 )); + $it->append(new RecursiveIteratorIterator( $directory10 )); + $it->append(new RecursiveIteratorIterator( $directory11 )); + break; + + // Search in source dir - only for test + case "100": + $directory1 = new RecursiveDirectoryIterator($ROSDir); + + $it = new AppendIterator(); + $it->append(new RecursiveIteratorIterator( $directory1 )); + break; + + default: + echo "Something is wrong! Please try again."; + exit; + } - function diff_versions($leftContent, $rightContent) - { - $diff = true; - $leftVersion = $rightVersion = null; + function diff_versions($leftContent, $rightContent) + { + $diff = true; + $leftVersion = $rightVersion = null; - // FIXME: Search multi-line with ""some text"" - $pattern = "/^(?!FONT|\\s*\\*|\\#\\include|\\s*\\ICON)[^\"\\n]*\"\\K(?!\\s*(?:\"|\\n))([^\"]+)/m"; + // FIXME: Search multi-line with ""some text"" + $pattern = "/^(?!FONT|\\s*\\*|\\#\\include|\\s*\\ICON)[^\"\\n]*\"\\K(?!\\s*(?:\"|\\n))([^\"]+)/m"; - if (preg_match_all($pattern, $leftContent, $matches) <= 0) - { - throw new Exception('Left content has no version line.'); - } + if (preg_match_all($pattern, $leftContent, $matches) <= 0) + { + throw new Exception('Left content has no version line.'); + } - $leftVersion = $matches[1]; + $leftVersion = $matches[1]; - if (preg_match_all($pattern, $rightContent, $matches) <= 0) - { - throw new Exception('Right content has no version line.'); - } + if (preg_match_all($pattern, $rightContent, $matches) <= 0) + { + throw new Exception('Right content has no version line.'); + } - $rightVersion = $matches[1]; + $rightVersion = $matches[1]; - return array( - 'diff' => array_intersect($leftVersion, $rightVersion), - 'leftVersion' => $leftVersion, - 'rightVersion' => $rightVersion, - ); - } + return array( + 'diff' => array_intersect($leftVersion, $rightVersion), + 'leftVersion' => $leftVersion, + 'rightVersion' => $rightVersion, + ); + } - function exceptions_error_handler($severity, $message, $filename, $lineno) + function exceptions_error_handler($severity, $message, $filename, $lineno) + { + if (error_reporting() == 0) { - if (error_reporting() == 0) - { - return; - } - if (error_reporting() & $severity) - { - throw new ErrorException($message, 0, $severity, $filename, $lineno); - } + return; + } + if (error_reporting() & $severity) + { + throw new ErrorException($message, 0, $severity, $filename, $lineno); } + } - set_error_handler('exceptions_error_handler'); + set_error_handler('exceptions_error_handler'); - $regex = new RegexIterator($it, '/^.+'. $langDir .'.+('. $originLang .')\.'. $fileExt .'$/i', RecursiveRegexIterator::GET_MATCH); + $regex = new RegexIterator($it, '/^.+'. $langDir .'.+('. $originLang .')\.'. $fileExt .'$/i', RecursiveRegexIterator::GET_MATCH); - $missing = $allStrings = 0; + $missing = $allStrings = 0; - $lang = htmlspecialchars($_GET["lang"]); - // Search for eg. PL,Pl,pl - $fileSearch = strtoupper($lang) .",". ucfirst($lang) .",". strtolower($lang); + $lang = htmlspecialchars($_GET["lang"]); + // Search for eg. PL,Pl,pl + $fileSearch = strtoupper($lang) .",". ucfirst($lang) .",". strtolower($lang); - // ReactOS and Wine Strings - array - $ignoredROSStrings = file($ROSSpellFilename, FILE_IGNORE_NEW_LINES); - $ignoredWineStrings = file($wineSpellFilename, FILE_IGNORE_NEW_LINES); + // ReactOS and Wine Strings - array + $ignoredROSStrings = file($ROSSpellFilename, FILE_IGNORE_NEW_LINES); + $ignoredWineStrings = file($wineSpellFilename, FILE_IGNORE_NEW_LINES); - $regex->rewind(); - while($regex->valid()) + $regex->rewind(); + while($regex->valid()) + { + if (!$regex->isDot()) { - if (!$regex->isDot()) + $file = glob($regex->getPathInfo() ."/*{". $fileSearch ."}*.". $fileExt, GLOB_BRACE); + + $isFile = array_filter($file); + + if (empty($isFile)) + { + echo 'No translation for path '. $regex->getPathInfo() .'
'; + } + else { - $file = glob($regex->getPathInfo() ."/*{". $fileSearch ."}*.". $fileExt, GLOB_BRACE); + $fileContent1 = file_get_contents($regex->key()); + $fileContent2 = file_get_contents($file[0]); - $isFile = array_filter($file); + $array = diff_versions($fileContent1, $fileContent2); - if (empty($isFile)) - { - echo 'No translation for path '. $regex->getPathInfo() .'
'; - } - else + if ($array['diff']) { - $fileContent1 = file_get_contents($regex->key()); - $fileContent2 = file_get_contents($file[0]); + echo $regex->getPathInfo() .'

'; - $array = diff_versions($fileContent1, $fileContent2); + $currentMissing = $missing; - if ($array['diff']) + foreach ($array['leftVersion'] as $index => $english) { - echo $regex->getPathInfo() .'

'; - - $currentMissing = $missing; - - foreach ($array['leftVersion'] as $index => $english) + // Catch offset error + try { - // Catch offset error - try + // Check if this same and ignore some words + if ($english === $array['rightVersion'][$index] && !in_array($english, $ignoredROSStrings) && !in_array($english, $ignoredWineStrings)) { - // Check if this same and ignore some words - if ($english === $array['rightVersion'][$index] && !in_array($english, $ignoredROSStrings) && !in_array($english, $ignoredWineStrings)) - { - echo "Missing translation: ". htmlspecialchars($english) ."
"; - $missing++; - } - $allStrings++; - } - catch (Exception $e) - { - echo "Missing stuff in your language
"; - $allStrings++; + echo "Missing translation: ". htmlspecialchars($english) ."
"; $missing++; } + $allStrings++; + } + catch (Exception $e) + { + echo "Missing stuff in your language
"; + $allStrings++; + $missing++; } - if ($currentMissing == $missing) - echo "Seems OK :) Some strings was ignored by ReactOS and Wine spell files.
"; - - echo "
"; } + if ($currentMissing == $missing) + echo "Seems OK :) Some strings was ignored by ReactOS and Wine spell files.
"; + + echo "
"; } } - $regex->next(); } - echo "

All strings for english: $allStrings

"; - echo "

Missing translations for your language ($lang): $missing

"; - - // Rounded percent - $percent = round((($allStrings - $missing) / $allStrings) * 100, 2); - echo "

Language $lang translated in $percent%

"; + $regex->next(); } + echo "

All strings for english: $allStrings

"; + echo "

Missing translations for your language ($lang): $missing

"; + + // Rounded percent + $percent = round((($allStrings - $missing) / $allStrings) * 100, 2); + echo "

Language $lang translated in $percent%

"; +} include_once('footer.php'); ?> \ No newline at end of file diff --git a/encoding.php b/encoding.php index 0c8aa07..d091b88 100644 --- a/encoding.php +++ b/encoding.php @@ -17,137 +17,137 @@ require_once('config.php'); ?> -
-
-
- Please type your language code in ISO 639-1. For example: pl for Polish, de for German -
- -
- " id="lang" name="lang" class="form-control input-md" required="required" autofocus="autofocus" pattern="[A-Za-z]{2}" title="Two letter language code"/> -
+
+ +
+Please type your language code in ISO 639-1. For example: pl for Polish, de for German +
+ +
+ " id="lang" name="lang" class="form-control input-md" required="required" autofocus="autofocus" pattern="[A-Za-z]{2}" title="Two letter language code"/>
-
- -
- -
+
+
+ +
+
-
- -
-
- -
-
+
+
+ +
+
+ +
+
- append(new RecursiveIteratorIterator( $directory1 )); - $it->append(new RecursiveIteratorIterator( $directory2 )); - $it->append(new RecursiveIteratorIterator( $directory3 )); - $it->append(new RecursiveIteratorIterator( $directory4 )); - $it->append(new RecursiveIteratorIterator( $directory5 )); - break; - - case "2": - $directory6 = new RecursiveDirectoryIterator($ROSDir. "dll/cpl"); - $directory7 = new RecursiveDirectoryIterator($ROSDir. "dll/shellext"); - $directory8 = new RecursiveDirectoryIterator($ROSDir. "dll/win32"); - - $it = new AppendIterator(); - $it->append(new RecursiveIteratorIterator( $directory6 )); - $it->append(new RecursiveIteratorIterator( $directory7 )); - $it->append(new RecursiveIteratorIterator( $directory8 )); - break; - - case "3": - $directory9 = new RecursiveDirectoryIterator($ROSDir. "media/themes"); - $directory10 = new RecursiveDirectoryIterator($ROSDir. "subsystems/mvdm/ntvdm"); - $directory11 = new RecursiveDirectoryIterator($ROSDir. "win32ss/user"); - - $it = new AppendIterator(); - $it->append(new RecursiveIteratorIterator( $directory9 )); - $it->append(new RecursiveIteratorIterator( $directory10 )); - $it->append(new RecursiveIteratorIterator( $directory11 )); - break; - - // Search in source dir - only for test - case "100": - $directory1 = new RecursiveDirectoryIterator($ROSDir); - - $it = new AppendIterator(); - $it->append(new RecursiveIteratorIterator( $directory1 )); - break; - - default: - echo "Something is wrong! Please try again."; - exit; - } + case "1": + $directory1 = new RecursiveDirectoryIterator($ROSDir. "base/applications"); + $directory2 = new RecursiveDirectoryIterator($ROSDir. "base/setup"); + $directory3 = new RecursiveDirectoryIterator($ROSDir. "base/shell"); + $directory4 = new RecursiveDirectoryIterator($ROSDir. "base/system"); + $directory5 = new RecursiveDirectoryIterator($ROSDir. "boot/freeldr/fdebug"); + + $it = new AppendIterator(); + $it->append(new RecursiveIteratorIterator( $directory1 )); + $it->append(new RecursiveIteratorIterator( $directory2 )); + $it->append(new RecursiveIteratorIterator( $directory3 )); + $it->append(new RecursiveIteratorIterator( $directory4 )); + $it->append(new RecursiveIteratorIterator( $directory5 )); + break; + + case "2": + $directory6 = new RecursiveDirectoryIterator($ROSDir. "dll/cpl"); + $directory7 = new RecursiveDirectoryIterator($ROSDir. "dll/shellext"); + $directory8 = new RecursiveDirectoryIterator($ROSDir. "dll/win32"); + + $it = new AppendIterator(); + $it->append(new RecursiveIteratorIterator( $directory6 )); + $it->append(new RecursiveIteratorIterator( $directory7 )); + $it->append(new RecursiveIteratorIterator( $directory8 )); + break; + + case "3": + $directory9 = new RecursiveDirectoryIterator($ROSDir. "media/themes"); + $directory10 = new RecursiveDirectoryIterator($ROSDir. "subsystems/mvdm/ntvdm"); + $directory11 = new RecursiveDirectoryIterator($ROSDir. "win32ss/user"); + + $it = new AppendIterator(); + $it->append(new RecursiveIteratorIterator( $directory9 )); + $it->append(new RecursiveIteratorIterator( $directory10 )); + $it->append(new RecursiveIteratorIterator( $directory11 )); + break; + + // Search in source dir - only for test + case "100": + $directory1 = new RecursiveDirectoryIterator($ROSDir); + + $it = new AppendIterator(); + $it->append(new RecursiveIteratorIterator( $directory1 )); + break; + + default: + echo "Something is wrong! Please try again."; + exit; + } - $regex = new RegexIterator($it, '/^.+'. $langDir .'.+('. $originLang .')\.'. $fileExt .'$/i', RecursiveRegexIterator::GET_MATCH); + $regex = new RegexIterator($it, '/^.+'. $langDir .'.+('. $originLang .')\.'. $fileExt .'$/i', RecursiveRegexIterator::GET_MATCH); - $allWrongEnc = 0; + $allWrongEnc = 0; - $lang = htmlspecialchars($_GET["lang"]); - // Search for eg. PL,Pl,pl - $fileSearch = strtoupper($lang) .",". ucfirst($lang) .",". strtolower($lang); + $lang = htmlspecialchars($_GET["lang"]); + // Search for eg. PL,Pl,pl + $fileSearch = strtoupper($lang) .",". ucfirst($lang) .",". strtolower($lang); - // UTF-8 BOM starts with EF BB BF - define ('UTF8_BOM', chr(0xEF) . chr(0xBB) . chr(0xBF)); + // UTF-8 BOM starts with EF BB BF + define ('UTF8_BOM', chr(0xEF) . chr(0xBB) . chr(0xBF)); - $regex->rewind(); - while($regex->valid()) + $regex->rewind(); + while($regex->valid()) + { + if (!$regex->isDot()) { - if (!$regex->isDot()) - { - $file = glob($regex->getPathInfo() ."/*{". $fileSearch ."}*.". $fileExt, GLOB_BRACE); + $file = glob($regex->getPathInfo() ."/*{". $fileSearch ."}*.". $fileExt, GLOB_BRACE); - $isFile = array_filter($file); + $isFile = array_filter($file); - if (!empty($isFile)) + if (!empty($isFile)) + { + $text = file_get_contents($file[0]); + // UTF-8 is good + if (mb_check_encoding($text, 'UTF-8')) { - $text = file_get_contents($file[0]); - // UTF-8 is good - if (mb_check_encoding($text, 'UTF-8')) - { - $first3 = substr($text, 0, 3); - // But UTF-8 with BOM not! - if ($first3 === UTF8_BOM) - { - echo 'Detected UTF-8 BOM in '. $file[0] .'
'; - $allWrongEnc++; - } - } - // Other encoding - else + $first3 = substr($text, 0, 3); + // But UTF-8 with BOM not! + if ($first3 === UTF8_BOM) { - echo 'Detected other encoding in '. $file[0] .'
'; + echo 'Detected UTF-8 BOM in '. $file[0] .'
'; $allWrongEnc++; } } + // Other encoding + else + { + echo 'Detected other encoding in '. $file[0] .'
'; + $allWrongEnc++; + } } - $regex->next(); } - echo "

All files with wrong encoding: $allWrongEnc

"; + $regex->next(); } + echo "

All files with wrong encoding: $allWrongEnc

"; +} include_once('footer.php'); ?> \ No newline at end of file