forked from OpenWF/Translations
		
	
		
			
				
	
	
		
			47 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			47 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
function extract_strings($cont)
 | 
						|
{
 | 
						|
	preg_match_all("/([A-Za-z_ ]+): (.*)/", $cont, $matches, PREG_SET_ORDER, 0);
 | 
						|
	$strings = [];
 | 
						|
	foreach ($matches as $match)
 | 
						|
	{
 | 
						|
		$strings[$match[1]] = $match[2];
 | 
						|
	}
 | 
						|
	return $strings;
 | 
						|
}
 | 
						|
 | 
						|
$source = file_get_contents("bootstrapper/en.cat.txt");
 | 
						|
$source_strings = extract_strings($source);
 | 
						|
$source_lines = explode("\n", $source);
 | 
						|
 | 
						|
foreach (scandir("bootstrapper") as $file)
 | 
						|
{
 | 
						|
	if (is_file("bootstrapper/$file") && $file != "en.cat.txt")
 | 
						|
	{
 | 
						|
		$cont = file_get_contents("bootstrapper/$file");
 | 
						|
		$target_strings = extract_strings($cont);
 | 
						|
		$fh = fopen("bootstrapper/$file", "wb");
 | 
						|
		foreach ($source_lines as $line)
 | 
						|
		{
 | 
						|
			if ($strings = extract_strings($line))
 | 
						|
			{
 | 
						|
				foreach ($strings as $key => $value)
 | 
						|
				{
 | 
						|
					if (array_key_exists($key, $target_strings))
 | 
						|
					{
 | 
						|
						fwrite($fh, "$key: $target_strings[$key]\n");
 | 
						|
					}
 | 
						|
					else
 | 
						|
					{
 | 
						|
						fwrite($fh, "$key: [UNTRANSLATED] $value\n");
 | 
						|
					}
 | 
						|
				}
 | 
						|
			}
 | 
						|
			else
 | 
						|
			{
 | 
						|
				fwrite($fh, $line."\n");
 | 
						|
			}
 | 
						|
		}
 | 
						|
	}
 | 
						|
}
 |