Commit 2f05321f authored by haemmer's avatar haemmer

Added option to output all strings of en and another language

parent 77eba402
<?php
/*
Usage:
* php check-locales.php
Checks all language strings against the reference language (Enlish).
It is checked whether a string is missing, obsolete and whether it contains
the same number of macros.
* php check-locales.php [langauge]
e.g. php check-locales.php fr
Outputs a HTML document that contains all strings of the reference language
(English) and [language]. This allows to easier spot discrepancies and
retranslate strings.
*/
// This script checks for missing and incomplete locales
if (isset($_SERVER['REMOTE_ADDR'])){
exit('No direct script access allowed');
......@@ -7,9 +23,52 @@ if (isset($_SERVER['REMOTE_ADDR'])){
require_once('languages.php');
include('custom-languages.php');
echo "The following problems were found:\n";
$refLang = 'en';
foreach(array_keys($langStrings) as $lang){
if ($argc > 1){
$refLang = $argv[1];
echo <<<HEADER
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<h2>Output all "{$refLang}' language strings</h2>
<dl>
HEADER;
foreach ($langStrings['en'] as $k => $v){
echo "<dt style='font-weigth: bold; color: purple;'>String: ".$k."</dt>\n<dd>\n";
echo "<strong>[en]:</strong> <span style='color: gray'>";
if (substr_count($langStrings['en'][$k], '%s') > 0) {
echo sprintf($langStrings['en'][$k], 'https://example.value/1', 'https://example.value/2');
} else {
echo $langStrings['en'][$k];
}
echo "</span><br />\n";
echo "<strong>[".$refLang."]:</strong> ";
if (isset($langStrings[$refLang][$k]) && substr_count($langStrings[$refLang][$k], '%s') > 0){
echo sprintf($langStrings[$refLang][$k], 'https://example.value/1', 'https://example.value/2');
} elseif (isset($langStrings[$refLang][$k])) {
echo $langStrings[$refLang][$k];
} else {
echo "---Missing---";
}
echo "\n</dd>\n";
}
echo <<<FOOTER
</dl>
</html>
FOOTER;
} else {
echo "The following problems were found:\n";
$refLang = 'en';
foreach(array_keys($langStrings) as $lang){
if ($lang == 'en'){
continue;
}
......@@ -30,6 +89,7 @@ foreach(array_keys($langStrings) as $lang){
echo "In $lang obsolete locale $k\n";
}
}
}
}
?>
\ 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