From b1876aa71999a882054361c20c1d433ab0d435b9 Mon Sep 17 00:00:00 2001 From: EV-soft Date: Sun, 13 Jun 2021 09:03:59 +0200 Subject: [PATCH] Create CreateLanguage.php This file creates a sorted language list based on a scan of the most recent source file (s) --- CreateLanguage.php | 78 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 CreateLanguage.php diff --git a/CreateLanguage.php b/CreateLanguage.php new file mode 100644 index 0000000..ebdbe94 --- /dev/null +++ b/CreateLanguage.php @@ -0,0 +1,78 @@ +".'Projektscann: '."
"; + echo "
".'Scanning for prefix: "lng(\'" '." in .php/.htm files in current folder,"; + echo "
and create a complete list of language texts that you can translate"; + echo '

'; + + while (false !== ($entry = $d->read())) { + $dir= $entry.'/'; + if (is_dir($entry) ) { + $files = scandir($dir); + if ($files) + foreach ($files as $source) { $count= 0; $search= "lng('"; + if (($source!=='.') and ($source!=='..') + and (!strpos($source,'.bak')) and (!strpos($source,'lngScann.php')) and (!strpos($source,'.csv')) + and ((strpos($source,'.php')) or (strpos($source,'.htm'))) ) + { $lines = file($dir.$source); + foreach ($lines as $line_num => $line) { + $line= ' '.$line; + if ($a=strpos($line,$search)) { + if ((strpos($source,'.php')) or (strpos($source,'.htm'))) { + $str= $line; + while (strpos($str,$search)) { + $a= strpos($str,$search); $str= substr($str,$a+5); $b= strpos($str,"')"); + $str= html_entity_decode($str); + $str= strip_tags($str); + $longest= max($longest,strlen(utf8_decode(substr($str,0,$b)))); + $f= substr($str,0,$b); + $arrStrings[] = ['"'.$f.'"']; + } + } $count++; $total++; + } + } + $count= substr('000'.$count,-4); + if ($count>0) $buff[] = 'Total: '.$count.' found : "'.$search.'" i '.$dir.''.$source.'
'; + } + } + } + } + echo '

'; + $d->close(); + foreach ($buff as $buf) {echo $buf;}; + echo '
Total: '.$total. ' found: '.$search.' in the scanned files
'; + $arrStrings= array_unique($arrStrings, SORT_REGULAR); + // sort($arrStrings, SORT_NATURAL | SORT_FLAG_CASE); + sort($arrStrings); + echo '
Sorted list without duplicates:'; + echo '

'; +echo '

+{
+  "appName": "Tiny File Manager",
+  "version": "2.4.6",
+  "language": [
+    {
+      "name": "Fill: English name for the language",
+      "code": "Fill: language ISO code",
+      "translation": {';
+        foreach ($arrStrings as $string) 
+        {if (strlen($string[0])>3) 
+            echo '
'.str_repeat(" ",8).$string[0].':'. + str_repeat(" ",$longest+3-strlen(utf8_decode(substr($string[0],0)))). + '"Missing_native_translated_string",'; + }; +echo ' <- REMOVE THIS LAST COMMA ! + } + }, + {... Insert all other languages here ...} + ] +} +
'; + echo '

'; + echo '
Total: '.count($arrStrings).' strings i the sorted list. Longest string is on '.$longest.' chars.'; + echo '
You can copy - paste this list to your editor'; + echo '
Remember to escape the char: " with a slash like this: \" if it occurs on translated text !'; +?>