MOBILE-3833 lang: Improve language scripts
This commit is contained in:
		
							parent
							
								
									7cc309275c
								
							
						
					
					
						commit
						347d08f806
					
				| @ -113,10 +113,17 @@ function add_langs_to_config($langs, $config) { | ||||
|         $config['languages'] = json_decode( json_encode( $config['languages'] ), true ); | ||||
|         ksort($config['languages']); | ||||
|         $config['languages'] = json_decode( json_encode( $config['languages'] ), false ); | ||||
|         file_put_contents(CONFIG, json_encode($config, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT)); | ||||
|         save_json(CONFIG, $config); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  * Save json data. | ||||
|  */ | ||||
| function save_json($path, $content) { | ||||
|     file_put_contents($path, str_replace('\/', '/', json_encode($content, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT))."\n"); | ||||
| } | ||||
| 
 | ||||
| function get_langfolder($lang) { | ||||
|     $folder = LANGPACKSFOLDER.'/'.str_replace('-', '_', $lang); | ||||
|     if (!is_dir($folder) || !is_file($folder.'/langconfig.php')) { | ||||
| @ -271,7 +278,7 @@ function build_lang($lang, $keys) { | ||||
| 
 | ||||
|     // Sort and save.
 | ||||
|     ksort($translations); | ||||
|     file_put_contents(ASSETSPATH.$lang.'.json', str_replace('\/', '/', json_encode($translations, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT))); | ||||
|     save_json(ASSETSPATH.$lang.'.json', $translations); | ||||
| 
 | ||||
|     $success = count($translations); | ||||
|     $percentage = floor($success/$total * 100); | ||||
| @ -366,7 +373,7 @@ function save_key($key, $value, $filePath) { | ||||
|     if (!isset($file[$key]) || $file[$key] != $value) { | ||||
|         $file[$key] = $value; | ||||
|         ksort($file); | ||||
|         file_put_contents($filePath, str_replace('\/', '/', json_encode($file, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT))); | ||||
|         save_json($filePath, $file); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
|  | ||||
| @ -124,6 +124,9 @@ function get_language { | ||||
| # Entry function to get all language files. | ||||
| function get_languages { | ||||
|     suffix=$1 | ||||
|     if [ -z $suffix ]; then | ||||
|         suffix='' | ||||
|     fi | ||||
| 
 | ||||
|     get_last_version | ||||
| 
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user