forked from OpenWF/Translations
		
	Add update script
This commit is contained in:
		
							parent
							
								
									388a884343
								
							
						
					
					
						commit
						29a38530a2
					
				@ -39,4 +39,4 @@ dict = {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	err: `Connexion au DLL perdue.`,
 | 
						err: `Connexion au DLL perdue.`,
 | 
				
			||||||
	err_retry: `Tentative de reconnexion.`,
 | 
						err_retry: `Tentative de reconnexion.`,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -39,4 +39,4 @@ dict = {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	err: `Соединение с DLL потеряно.`,
 | 
						err: `Соединение с DLL потеряно.`,
 | 
				
			||||||
	err_retry: `Попытка восстановить соединение.`,
 | 
						err_retry: `Попытка восстановить соединение.`,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -39,4 +39,4 @@ dict = {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	err: `与DLL连接丢失。`,
 | 
						err: `与DLL连接丢失。`,
 | 
				
			||||||
	err_retry: `尝试重连。`,
 | 
						err_retry: `尝试重连。`,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										47
									
								
								update.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										47
									
								
								update.php
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,47 @@
 | 
				
			|||||||
 | 
					<?php
 | 
				
			||||||
 | 
					function extract_strings($cont)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						preg_match_all("/([a-z_]+): `([^`]*)`,/", $cont, $matches, PREG_SET_ORDER, 0);
 | 
				
			||||||
 | 
						$strings = [];
 | 
				
			||||||
 | 
						foreach ($matches as $match)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							$strings[$match[1]] = $match[2];
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return $strings;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					$source = file_get_contents("client-webui/en.js");
 | 
				
			||||||
 | 
					$source_strings = extract_strings($source);
 | 
				
			||||||
 | 
					$source_lines = explode("\n", $source);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					foreach (scandir("client-webui") as $file)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						if (is_file("client-webui/$file") && $file != "en.js")
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							$cont = file_get_contents("client-webui/$file");
 | 
				
			||||||
 | 
							$target_strings = extract_strings($cont);
 | 
				
			||||||
 | 
							$fh = fopen("client-webui/$file", "wb");
 | 
				
			||||||
 | 
							fwrite($fh, explode("\n", $cont)[0]."\n");
 | 
				
			||||||
 | 
							foreach ($source_lines as $line)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								if ($strings = extract_strings($line))
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									foreach ($strings as $key => $value)
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										if (array_key_exists($key, $target_strings))
 | 
				
			||||||
 | 
										{
 | 
				
			||||||
 | 
											fwrite($fh, "\t$key: `$target_strings[$key]`,\n");
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
										else
 | 
				
			||||||
 | 
										{
 | 
				
			||||||
 | 
											fwrite($fh, "\t$key: `[UNTRANSLATED] $value`,\n");
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								else
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									fwrite($fh, $line."\n");
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user