mirror of
https://github.com/prasathmani/tinyfilemanager
synced 2024-06-07 16:32:15 +02:00
Update CreateLanguage.php
Can now analyze existing languages and specify status
This commit is contained in:
parent
b1876aa719
commit
d0f6eafd1f
|
@ -1,13 +1,34 @@
|
||||||
<?php ## EV-soft - 2021-06-13
|
<?php ## EV-soft - 2021-06-13
|
||||||
## to: Create / Update / Maintain list of translate strings by scanning the source-file(s)
|
## to: Create / Update / Maintain list of translate strings by scanning the source-file(s)
|
||||||
## Place this file in the same folder as tinyfilemanager.php and read the file in your browser
|
## Place this file in the same folder as tinyfilemanager.php and read the file in your browser
|
||||||
|
if (!isset($compareCode))
|
||||||
|
$compareCode= 'ru'; ## Adjust this code to the default language you want to analyze (cant use 'en')
|
||||||
$d = dir("./");
|
$d = dir("./");
|
||||||
$total= 0; $buff= array(); $arrStrings= array(); $longest= 0;
|
$total= 0; $buff= array(); $arrStrings= array(); $longest= 0; $miss= 0;
|
||||||
|
echo '<meta charset="utf-8">';
|
||||||
echo "<br><big>".'Projektscann: '."</big><br>";
|
echo "<br><big>".'Projektscann: '."</big><br>";
|
||||||
echo "<br>".'Scanning for prefix: "lng(\'" '." in .php/.htm files in current folder,";
|
echo "<br>".'Scanning for prefix: "lng(\'" '." in .php/.htm files in current folder,";
|
||||||
echo "<br>and create a complete list of language texts that you can translate";
|
echo "<br>and create a complete list of language texts that you can translate";
|
||||||
echo '<p style="font-family:courier; font-size:18; ">';
|
echo '<p style="font-family:courier; font-size:18; ">';
|
||||||
|
$arrTrans= []; $arrCode= [];
|
||||||
|
$content = file_get_contents('translation.json');
|
||||||
|
if($content !== FALSE) {
|
||||||
|
$lng = json_decode($content, TRUE);
|
||||||
|
foreach ($lng["language"] as $key => $value) {
|
||||||
|
$code = $value["code"];
|
||||||
|
$lang_list[$code] = $value["name"];
|
||||||
|
$arrTrans[$code] = $value["translation"];
|
||||||
|
$arrCode[]= $code;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
echo '<form action="#" method="post">
|
||||||
|
<label for="lngCode">Select a code:</label>
|
||||||
|
<select id="lngCode" name="lngCode">';
|
||||||
|
foreach ($arrCode as $code) echo '<option value="'.$code.'" '.($code==$compareCode ? 'selected ' : '').' >'.$code.'</option>';
|
||||||
|
echo '</select>
|
||||||
|
<input type="submit" name="submit" value="Analyze Selected" />
|
||||||
|
</form>';
|
||||||
|
if (isset($_POST['submit'])) $compareCode = $_POST['lngCode'];
|
||||||
while (false !== ($entry = $d->read())) {
|
while (false !== ($entry = $d->read())) {
|
||||||
$dir= $entry.'/';
|
$dir= $entry.'/';
|
||||||
if (is_dir($entry) ) {
|
if (is_dir($entry) ) {
|
||||||
|
@ -35,7 +56,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$count= substr('000'.$count,-4);
|
$count= substr('000'.$count,-4);
|
||||||
if ($count>0) $buff[] = 'Total: '.$count.' found : "<font color=red>'.$search.'</font>" i <i>'.$dir.'</i><b>'.$source.'</b><br>';
|
if ($count>0) $buff[] = 'Total: '.$count.' found : "<font color=red>'.$search.'</font>" in file <i>'.$dir.'</i><b>'.$source.'</b><br>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,7 +68,7 @@
|
||||||
$arrStrings= array_unique($arrStrings, SORT_REGULAR);
|
$arrStrings= array_unique($arrStrings, SORT_REGULAR);
|
||||||
// sort($arrStrings, SORT_NATURAL | SORT_FLAG_CASE);
|
// sort($arrStrings, SORT_NATURAL | SORT_FLAG_CASE);
|
||||||
sort($arrStrings);
|
sort($arrStrings);
|
||||||
echo '<br>Sorted list without duplicates:';
|
echo '<br>Sorted list without duplicates for code: '.$compareCode;
|
||||||
echo '<p style="font-family:courier; font-size:11; ">';
|
echo '<p style="font-family:courier; font-size:11; ">';
|
||||||
echo '<pre>
|
echo '<pre>
|
||||||
{
|
{
|
||||||
|
@ -55,16 +76,20 @@ echo '<pre>
|
||||||
"version": "2.4.6",
|
"version": "2.4.6",
|
||||||
"language": [
|
"language": [
|
||||||
{
|
{
|
||||||
"name": "Fill: English name for the language",
|
"name": "<font color=red>Fill: English name for the language</font>",
|
||||||
"code": "Fill: language ISO code",
|
"code": "<font color=red>Fill: language ISO code</font>",
|
||||||
"translation": {';
|
"translation": {';
|
||||||
foreach ($arrStrings as $string)
|
foreach ($arrStrings as $string) {
|
||||||
{if (strlen($string[0])>3)
|
if (strlen($string[0])>3) {
|
||||||
echo '<br>'.str_repeat(" ",8).$string[0].':'.
|
echo '<br>'.str_repeat(" ",8).$string[0].':'.
|
||||||
str_repeat(" ",$longest+3-strlen(utf8_decode(substr($string[0],0)))).
|
str_repeat(" ",$longest+3-strlen(utf8_decode(substr($string[0],0))));
|
||||||
'"Missing_native_translated_string",';
|
if (array_key_exists(trim($string[0],'"'),$arrTrans[$compareCode])) {
|
||||||
};
|
echo '"'.$arrTrans[$compareCode][trim($string[0],'"')].'",';
|
||||||
echo ' <- REMOVE THIS LAST COMMA !
|
$miss++;
|
||||||
|
}
|
||||||
|
else echo '"<font color=red>Missing_native_translated_string</font>",';
|
||||||
|
}};
|
||||||
|
echo ' <font color=red><- REMOVE THIS LAST COMMA !</font>
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{... Insert all other languages here ...}
|
{... Insert all other languages here ...}
|
||||||
|
@ -74,5 +99,6 @@ echo ' <- REMOVE THIS LAST COMMA !
|
||||||
echo '</p>';
|
echo '</p>';
|
||||||
echo '<br>Total: '.count($arrStrings).' strings i the sorted list. Longest string is on '.$longest.' chars.';
|
echo '<br>Total: '.count($arrStrings).' strings i the sorted list. Longest string is on '.$longest.' chars.';
|
||||||
echo '<br>You can copy - paste this list to your editor';
|
echo '<br>You can copy - paste this list to your editor';
|
||||||
echo '<br>Remember to escape the char: " with a slash like this: \" if it occurs on translated text !';
|
echo '<br><font color=red>Remember to escape the char: " </font>with a slash like this: \" if it occurs on translated text !';
|
||||||
|
echo '<br>Status of the analyzed language is '.round($miss / count($arrStrings) * 100).' % translated.';
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Reference in a new issue