forked from CIT/Vmeda.Online
		
	MOBILE-3213 strings: Have a better CLI interface
This commit is contained in:
		
							parent
							
								
									4727194f54
								
							
						
					
					
						commit
						9e9b4bcbbe
					
				| @ -58,6 +58,7 @@ function build_languages($languages, $keys, $added_langs = []) { | ||||
| } | ||||
| 
 | ||||
| function get_langindex_keys() { | ||||
|     $local = 0; | ||||
|     // Process the index file, just once.
 | ||||
|     $keys = file_get_contents('langindex.json'); | ||||
|     $keys = (array) json_decode($keys); | ||||
| @ -67,6 +68,7 @@ function get_langindex_keys() { | ||||
|         if ($value == 'local_moodlemobileapp') { | ||||
|             $map->file = $value; | ||||
|             $map->string = $key; | ||||
|             $local++; | ||||
|         } else { | ||||
|             $exp = explode('/', $value, 2); | ||||
|             $map->file = $exp[0]; | ||||
| @ -87,7 +89,7 @@ function get_langindex_keys() { | ||||
|     } | ||||
| 
 | ||||
|     $total = count($keys); | ||||
|     echo "Total strings to translate $total\n"; | ||||
|     echo "Total strings to translate $total ($local local)\n"; | ||||
| 
 | ||||
|     return $keys; | ||||
| } | ||||
| @ -248,7 +250,11 @@ function build_lang($lang, $keys) { | ||||
| 
 | ||||
|     $success = count($translations); | ||||
|     $percentage = floor($success/$total * 100); | ||||
|     echo "\t\t$success of $total -> $percentage% ($local local)\n"; | ||||
|     $bar = progressbar($percentage); | ||||
|     if (strlen($lang) <= 2 && !$parent) { | ||||
|         echo "\t"; | ||||
|     } | ||||
|     echo "\t\t$success of $total -> $percentage% $bar ($local local)\n"; | ||||
| 
 | ||||
|     if ($lang == 'en') { | ||||
|         generate_local_moodlemobileapp($keys, $translations); | ||||
| @ -258,6 +264,11 @@ function build_lang($lang, $keys) { | ||||
|     return true; | ||||
| } | ||||
| 
 | ||||
| function progressbar($percentage) { | ||||
|     $done = $percentage/10; | ||||
|     return "\t".str_repeat('=', $done) . str_repeat('-', 10-$done); | ||||
| } | ||||
| 
 | ||||
| function detect_lang($lang, $keys) { | ||||
|     $langfoldername = get_langfolder($lang); | ||||
|     if (!$langfoldername) { | ||||
| @ -275,12 +286,14 @@ function detect_lang($lang, $keys) { | ||||
|         return false; | ||||
|     } | ||||
| 
 | ||||
|     echo "Checking $lang"; | ||||
|     $title = $lang; | ||||
|     if ($parent != "" && $parent != $lang) { | ||||
|         echo " ($parent)"; | ||||
|         $title .= " ($parent)"; | ||||
|     } | ||||
|     $langname = $string['thislanguage']; | ||||
|     echo " ".$langname." -D"; | ||||
|     $title .= " ".$langname." -D"; | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|     // Add the translation to the array.
 | ||||
|     foreach ($keys as $key => $value) { | ||||
| @ -304,7 +317,10 @@ function detect_lang($lang, $keys) { | ||||
|     } | ||||
| 
 | ||||
|     $percentage = floor($success/$total * 100); | ||||
|     echo "\t\t$success of $total -> $percentage% ($local local)"; | ||||
|     $bar = progressbar($percentage); | ||||
| 
 | ||||
|     echo "Checking ".$title.str_repeat("\t", 7 - floor(mb_strlen($title, 'UTF-8')/8)); | ||||
|     echo "\t$success of $total -> $percentage% $bar ($local local)"; | ||||
|     if (($percentage > 75 && $local > 50) || ($percentage > 50 && $local > 75)) { | ||||
|         echo " \t DETECTED\n"; | ||||
|         return true; | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user