diff --git a/CreateLanguage.php b/CreateLanguage.php index ebdbe94..668f3cd 100644 --- a/CreateLanguage.php +++ b/CreateLanguage.php @@ -1,13 +1,34 @@ '; echo "
".'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 '

'; - + $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 '

+ + + +
'; + if (isset($_POST['submit'])) $compareCode = $_POST['lngCode']; while (false !== ($entry = $d->read())) { $dir= $entry.'/'; if (is_dir($entry) ) { @@ -35,7 +56,7 @@ } } $count= substr('000'.$count,-4); - if ($count>0) $buff[] = 'Total: '.$count.' found : "'.$search.'" i '.$dir.''.$source.'
'; + if ($count>0) $buff[] = 'Total: '.$count.' found : "'.$search.'" in file '.$dir.''.$source.'
'; } } } @@ -47,7 +68,7 @@ $arrStrings= array_unique($arrStrings, SORT_REGULAR); // sort($arrStrings, SORT_NATURAL | SORT_FLAG_CASE); sort($arrStrings); - echo '
Sorted list without duplicates:'; + echo '
Sorted list without duplicates for code: '.$compareCode; echo '

'; echo '

 {
@@ -55,16 +76,20 @@ echo '
   "version": "2.4.6",
   "language": [
     {
-      "name": "Fill: English name for the language",
-      "code": "Fill: language ISO code",
+      "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 ! + 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)))); + if (array_key_exists(trim($string[0],'"'),$arrTrans[$compareCode])) { + echo '"'.$arrTrans[$compareCode][trim($string[0],'"')].'",'; + $miss++; + } + else echo '"Missing_native_translated_string",'; + }}; +echo ' <- REMOVE THIS LAST COMMA ! } }, {... Insert all other languages here ...} @@ -74,5 +99,6 @@ echo ' <- REMOVE THIS LAST COMMA ! 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 !'; + echo '
Remember to escape the char: " with a slash like this: \" if it occurs on translated text !'; + echo '
Status of the analyzed language is '.round($miss / count($arrStrings) * 100).' % translated.'; ?>