Commit 2858a5cb authored by haemmer's avatar haemmer

Added two helper scripts

parent c9dff61c
<?php
// This script checks for missing and incomplete locales
if (isset($_SERVER['REMOTE_ADDR'])){
exit('No direct script access allowed');
}
require_once('languages.php');
include('custom-languages.php');
echo "The following problems were found:\n";
$refLang = 'en';
foreach(array_keys($langStrings) as $lang){
if ($lang == 'en'){
continue;
}
foreach ($langStrings['en'] as $k => $v){
if (!isset($langStrings[$lang][$k])){
echo "* In '$lang' missing locale '$k'\n";
} else if (substr_count($langStrings['en'][$k], '%s') != substr_count($langStrings[$lang][$k], '%s')){
echo "* In '$lang' the number of substitutions (%s) differ for '$k': ";
echo substr_count($langStrings['en'][$k], '%s').' vs '.substr_count($langStrings[$lang][$k], '%s');
echo "\n";
}
}
foreach ($langStrings[$lang] as $k => $v){
if (!isset($langStrings['en'][$k])){
echo "In $lang obsolete locale $k\n";
}
}
}
?>
\ No newline at end of file
<?php
// This script reads an existing config.php and generates
// a new file config.new.php merging the default configuration file
// config.dist.php with the (customized) config.php
if (isset($_SERVER['REMOTE_ADDR'])){
exit('No direct script access allowed');
}
if (!file_exists('config.dist.php')) {
die('The default configuration file config.dist.php does not exist in this directory!');
}
if (!file_exists('config.php')) {
die('The configuration file config.php does not exist in this directory!');
}
require_once('config.php');
echo "Parsing current configuration and default configuration...\n";
$fp = fopen('config.new.php', 'w');
$distConfigFile = file('config.dist.php');
$currentConfigFile = file('config.php');
$configSettings = Array();
foreach ($currentConfigFile as $line){
if (preg_match('|^\s*(\$(.+?)\s*=.+;)|', $line, $matches)){
$var = $matches[2];
$configSettings[$var] = $matches[1];
}
}
echo "Merging configurations...\n";
foreach ($distConfigFile as $line){
fwrite($fp, $line);
if (preg_match('|^(\s*)\/\/\$(.+) =|', $line, $matches)){
$indent = $matches[1];
$var = $matches[2];
if (isset($configSettings[$var])){
echo "* Using from current configuration: ";
echo $configSettings[$var]."\n";
$config = $indent.$configSettings[$var]."\n";
fwrite($fp, $config);
}
}
}
fclose($fp);
?>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment