Projekt

Obecné

Profil

Stáhnout (1.62 KB) Statistiky
| Větev: | Tag: | Revize:
1
#!/usr/local/bin/php -q
2
<?php
3

    
4
	/**
5
	 * This script will generate a report on the status of a language
6
	 * as compared to the master english translation.
7
	 *
8
	 * $Id: langcheck,v 1.5 2005/07/19 18:21:58 soranzo Exp $
9
	 */
10
	error_reporting(E_ALL);
11
	// Prevent timeouts (non-safe mode only)
12
	if (!ini_get('safe_mode')) set_time_limit(0);
13

    
14
	// Check arguments
15
	if (sizeof($_SERVER['argv']) != 2) {
16
		echo "Usage: langcheck <language>\n\n";
17
		echo "   <language> is the filename without the .php extension\n";
18
		exit;
19
	}
20
	elseif (!file_exists("{$_SERVER['argv'][1]}.php")) {
21
		echo "Error: File not found.\n";
22
		exit;
23
	}
24

    
25
	// Include english source file
26
	include('./english.php');
27

    
28
	$master = $lang;
29
	$master_keys = array_keys($lang);
30
	unset($lang);
31

    
32
	// Include target language file
33
	include("./{$_SERVER['argv'][1]}.php");
34
	$slave = $lang;
35
	$slave_keys = array_keys($lang);
36

    
37
	echo "Source file: english.php\n";
38
	echo "Target file: {$_SERVER['argv'][1]}.php\n\n";
39

    
40
	// Find missing values
41
	$diff = array_diff($master_keys, $slave_keys);
42
	echo "Missing Strings\n";
43
	echo "---------------\n\n";
44
	if (sizeof($diff) > 0) {
45
		foreach ($diff as $v) {
46
			echo "\$lang['{$v}'] = '", str_replace("'", "\\'", $master[$v]), "';\n";
47
		}
48
		echo "\n";
49
		echo "Translations: ", sizeof($master_keys) - sizeof($diff), "/", sizeof($master_keys), "\n\n";
50

    
51
	}
52
	else echo "None\n\n";
53

    
54
	// Find extra values (to be deleted)
55
	$diff = array_diff($slave_keys, $master_keys);
56
	echo "Deleted Strings\n";
57
	echo "---------------\n\n";
58
	if (sizeof($diff) > 0) {
59
		foreach ($diff as $v) {
60
			echo "\$lang['{$v}'] = '", str_replace("'", "\\'", $slave[$v]), "';\n";
61
		}
62
	}
63
	else echo "None\n";
64

    
65
?>
(17-17/32)