Skip to content

Commit

Permalink
Just formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Saibamen committed Sep 4, 2015
1 parent 7db2684 commit c3cf1e0
Show file tree
Hide file tree
Showing 2 changed files with 275 additions and 275 deletions.
328 changes: 164 additions & 164 deletions diff.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,208 +17,208 @@
require_once('config.php');
?>

<center>
<form method="GET" class="form-horizontal">
<fieldset>
<legend>Please type your <a href="https://beta.wikiversity.org/wiki/List_of_ISO_639-1_codes">language code in ISO 639-1</a>. For example: pl for Polish, de for German</legend>
<div class="form-group">
<label class="col-md-4 control-label" for="lang">Language code:</label>
<div class="col-md-4">
<input type="text" value="<?php echo isset($_SESSION['lang']) ? $_SESSION['lang'] : "" ?>" id="lang" name="lang" class="form-control input-md" required="required" autofocus="autofocus" pattern="[A-Za-z]{2}" title="Two letter language code"/>
</div>
<center>
<form method="GET" class="form-horizontal">
<fieldset>
<legend>Please type your <a href="https://beta.wikiversity.org/wiki/List_of_ISO_639-1_codes">language code in ISO 639-1</a>. For example: pl for Polish, de for German</legend>
<div class="form-group">
<label class="col-md-4 control-label" for="lang">Language code:</label>
<div class="col-md-4">
<input type="text" value="<?php echo isset($_SESSION['lang']) ? $_SESSION['lang'] : "" ?>" id="lang" name="lang" class="form-control input-md" required="required" autofocus="autofocus" pattern="[A-Za-z]{2}" title="Two letter language code"/>
</div>
<div class="form-group">
<label class="col-md-4 control-label" for="dir">Directories:</label>
<div class="col-md-4">
<select id="dir" name="dir" class="form-control">
<option value="1">base, boot</option>
<option value="2" <?php if(isset($_GET["dir"]) && $_GET["dir"] == '2'){echo("selected");}?>>dll</option>
<option value="3" <?php if(isset($_GET["dir"]) && $_GET["dir"] == '3'){echo("selected");}?>>media, subsystems, win32ss</option>
<option value="100" <?php if(isset($_GET["dir"]) && $_GET["dir"] == '100'){echo("selected");}?>>All ReactOS Source dir</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label" for="dir">Directories:</label>
<div class="col-md-4">
<select id="dir" name="dir" class="form-control">
<option value="1">base, boot</option>
<option value="2" <?php if(isset($_GET["dir"]) && $_GET["dir"] == '2'){echo("selected");}?>>dll</option>
<option value="3" <?php if(isset($_GET["dir"]) && $_GET["dir"] == '3'){echo("selected");}?>>media, subsystems, win32ss</option>
<option value="100" <?php if(isset($_GET["dir"]) && $_GET["dir"] == '100'){echo("selected");}?>>All ReactOS Source dir</option>
</select>
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary">Search</button>
</div>
</fieldset>
</form>
</center>
<br/>
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary">Search</button>
</div>
</fieldset>
</form>
</center>
<br/>

<?php
if (isset($_GET["lang"]) && !empty($_GET["lang"]) && isset($_GET["dir"]) && is_numeric($_GET["dir"]))
<?php
if (isset($_GET["lang"]) && !empty($_GET["lang"]) && isset($_GET["dir"]) && is_numeric($_GET["dir"]))
{
// Switch for directories
switch ($_GET["dir"])
{
// Switch for directories
switch ($_GET["dir"])
{
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;
}
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 '<b>No translation</b> for path '. $regex->getPathInfo() .'<hr>';
}
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 '<b>No translation</b> for path '. $regex->getPathInfo() .'<hr>';
}
else
if ($array['diff'])
{
$fileContent1 = file_get_contents($regex->key());
$fileContent2 = file_get_contents($file[0]);
echo $regex->getPathInfo() .'<br><br>';

$array = diff_versions($fileContent1, $fileContent2);
$currentMissing = $missing;

if ($array['diff'])
foreach ($array['leftVersion'] as $index => $english)
{
echo $regex->getPathInfo() .'<br><br>';

$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 "<b>Missing translation:</b> ". htmlspecialchars($english) ."<br>";
$missing++;
}
$allStrings++;
}
catch (Exception $e)
{
echo "Missing stuff in your language<br>";
$allStrings++;
echo "<b>Missing translation:</b> ". htmlspecialchars($english) ."<br>";
$missing++;
}
$allStrings++;
}
catch (Exception $e)
{
echo "Missing stuff in your language<br>";
$allStrings++;
$missing++;
}
if ($currentMissing == $missing)
echo "Seems OK :) Some strings was ignored by ReactOS and Wine spell files.<br>";

echo "<hr>";
}
if ($currentMissing == $missing)
echo "Seems OK :) Some strings was ignored by ReactOS and Wine spell files.<br>";

echo "<hr>";
}
}
$regex->next();
}
echo "<h3>All strings for english: $allStrings</h3>";
echo "<h3>Missing translations for your language ($lang): $missing</h3>";

// Rounded percent
$percent = round((($allStrings - $missing) / $allStrings) * 100, 2);
echo "<h3>Language $lang translated in $percent%</h3>";
$regex->next();
}
echo "<h3>All strings for english: $allStrings</h3>";
echo "<h3>Missing translations for your language ($lang): $missing</h3>";

// Rounded percent
$percent = round((($allStrings - $missing) / $allStrings) * 100, 2);
echo "<h3>Language $lang translated in $percent%</h3>";
}

include_once('footer.php');
?>
Loading

0 comments on commit c3cf1e0

Please sign in to comment.