Completed
Push — master ( d488ab...6453e7 )
by Stephen
53:31
created
tools/i18n/pot-ext-meta.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -7,9 +7,9 @@  discard block
 block discarded – undo
7 7
  * @subpackage tools
8 8
  */
9 9
 
10
-$pomo = dirname( dirname( dirname( __FILE__ ) ) ) . '/src/wp-includes/pomo';
10
+$pomo = dirname(dirname(dirname(__FILE__))).'/src/wp-includes/pomo';
11 11
 require_once "$pomo/po.php";
12
-require_once dirname( __FILE__ ) . '/makepot.php';
12
+require_once dirname(__FILE__).'/makepot.php';
13 13
 
14 14
 class PotExtMeta {
15 15
 
@@ -36,9 +36,9 @@  discard block
 block discarded – undo
36 36
 		$source = $makepot->get_first_lines($ext_filename);
37 37
 		$pot = '';
38 38
 		$po = new PO;
39
-		foreach($this->headers as $header) {
39
+		foreach ($this->headers as $header) {
40 40
 			$string = $makepot->get_addon_header($header, $source);
41
-			if (!$string) continue;
41
+			if ( ! $string) continue;
42 42
 			$args = array(
43 43
 				'singular' => $string,
44 44
 				'extracted_comments' => $header.' of the plugin/theme',
@@ -49,16 +49,16 @@  discard block
 block discarded – undo
49 49
 		return $pot;
50 50
 	}
51 51
 
52
-	function append( $ext_filename, $pot_filename, $headers = null ) {
53
-		if ( $headers )
52
+	function append($ext_filename, $pot_filename, $headers = null) {
53
+		if ($headers)
54 54
 			$this->headers = (array) $headers;
55
-		if ( is_dir( $ext_filename ) ) {
55
+		if (is_dir($ext_filename)) {
56 56
 			$pot = implode('', array_map(array($this, 'load_from_file'), glob("$ext_filename/*.php")));
57 57
 		} else {
58 58
 			$pot = $this->load_from_file($ext_filename);
59 59
 		}
60
-		$potf = '-' == $pot_filename? STDOUT : fopen($pot_filename, 'a');
61
-		if (!$potf) return false;
60
+		$potf = '-' == $pot_filename ? STDOUT : fopen($pot_filename, 'a');
61
+		if ( ! $potf) return false;
62 62
 		fwrite($potf, $pot);
63 63
 		if ('-' != $pot_filename) fclose($potf);
64 64
 		return true;
@@ -69,10 +69,10 @@  discard block
 block discarded – undo
69 69
 if ($included_files[0] == __FILE__) {
70 70
 	ini_set('display_errors', 1);
71 71
 	$potextmeta = new PotExtMeta;
72
-	if (!isset($argv[1])) {
72
+	if ( ! isset($argv[1])) {
73 73
 		$potextmeta->usage();
74 74
 	}
75
-	$potextmeta->append( $argv[1], isset( $argv[2] ) ? $argv[2] : '-', isset( $argv[3] ) ? $argv[3] : null );
75
+	$potextmeta->append($argv[1], isset($argv[2]) ? $argv[2] : '-', isset($argv[3]) ? $argv[3] : null);
76 76
 }
77 77
 
78 78
 ?>
Please login to merge, or discard this patch.
tools/i18n/not-gettexted.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -7,12 +7,12 @@  discard block
 block discarded – undo
7 7
  * @subpackage tools
8 8
  */
9 9
 // see: http://php.net/tokenizer
10
-if ( ! defined( 'T_ML_COMMENT' ) )
11
-	    define( 'T_ML_COMMENT', T_COMMENT );
10
+if ( ! defined('T_ML_COMMENT'))
11
+	    define('T_ML_COMMENT', T_COMMENT);
12 12
 else
13
-	    define( 'T_DOC_COMMENT', T_ML_COMMENT );
13
+	    define('T_DOC_COMMENT', T_ML_COMMENT);
14 14
 
15
-$pomo = dirname( dirname( dirname( __FILE__ ) ) ) . '/src/wp-includes/pomo';
15
+$pomo = dirname(dirname(dirname(__FILE__))).'/src/wp-includes/pomo';
16 16
 require_once "$pomo/po.php";
17 17
 require_once "$pomo/mo.php";
18 18
 
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 	var $STAGE_WHITESPACE_AFTER = 4;
27 27
 	var $STAGE_END_COMMENT = 4;
28 28
 
29
-	var $commands = array('extract' => 'command_extract', 'replace' => 'command_replace' );
29
+	var $commands = array('extract' => 'command_extract', 'replace' => 'command_replace');
30 30
 
31 31
 
32 32
 	function logmsg() {
@@ -34,8 +34,8 @@  discard block
 block discarded – undo
34 34
 		if ($this->enable_logging) error_log(implode(' ', $args));
35 35
 	}
36 36
 
37
-	function stderr($msg, $nl=true) {
38
-		fwrite(STDERR, $msg.($nl? "\n" : ""));
37
+	function stderr($msg, $nl = true) {
38
+		fwrite(STDERR, $msg.($nl ? "\n" : ""));
39 39
 	}
40 40
 
41 41
 	function cli_die($msg) {
@@ -43,19 +43,19 @@  discard block
 block discarded – undo
43 43
 		exit(1);
44 44
 	}
45 45
 
46
-	function unchanged_token($token, $s='') {
47
-		return is_array($token)? $token[1] : $token;
46
+	function unchanged_token($token, $s = '') {
47
+		return is_array($token) ? $token[1] : $token;
48 48
 	}
49 49
 
50
-	function ignore_token($token, $s='') {
50
+	function ignore_token($token, $s = '') {
51 51
 		return '';
52 52
 	}
53 53
 
54 54
 	function list_php_files($dir) {
55 55
 		$files = array();
56
-		$items = scandir( $dir );
57
-		foreach ( (array) $items as $item ) {
58
-			$full_item = $dir . '/' . $item;
56
+		$items = scandir($dir);
57
+		foreach ((array) $items as $item) {
58
+			$full_item = $dir.'/'.$item;
59 59
 			if ('.' == $item || '..' == $item)
60 60
 				continue;
61 61
 			if ('.php' == substr($item, -4))
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 		return create_function('$token, $string', 'global $'.$m.'; return var_export($'.$m.'->translate($string), true);');
78 78
 	}
79 79
 
80
-	function walk_tokens(&$tokens, $string_action, $other_action, $register_action=null) {
80
+	function walk_tokens(&$tokens, $string_action, $other_action, $register_action = null) {
81 81
 
82 82
 		$current_comment_id = '';
83 83
 		$current_string = '';
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 		$result = '';
87 87
 		$line = 1;
88 88
 
89
-		foreach($tokens as $token) {
89
+		foreach ($tokens as $token) {
90 90
 			if (is_array($token)) {
91 91
 				list($id, $text) = $token;
92 92
 				$line += substr_count($text, "\n");
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 						$stage = $this->STAGE_END_COMMENT;
103 103
 						$this->logmsg('end comment', $current_comment_id);
104 104
 						$result .= call_user_func($other_action, $token);
105
-						if (!is_null($register_action)) call_user_func($register_action, $current_string, $current_comment_id, $current_string_line);
105
+						if ( ! is_null($register_action)) call_user_func($register_action, $current_string, $current_comment_id, $current_string_line);
106 106
 						continue;
107 107
 					}
108 108
 				} else if (T_CONSTANT_ENCAPSED_STRING == $id) {
@@ -149,21 +149,21 @@  discard block
 block discarded – undo
149 149
 		$global_name = '__entries_'.mt_rand(1, 1000);
150 150
 		$GLOBALS[$global_name] = array();
151 151
 
152
-		foreach($filenames as $filename) {
152
+		foreach ($filenames as $filename) {
153 153
 			$tokens = token_get_all(file_get_contents($filename));
154 154
 			$aggregator = $this->make_string_aggregator($global_name, $filename);
155 155
 			$this->walk_tokens($tokens, array($this, 'ignore_token'), array($this, 'ignore_token'), $aggregator);
156 156
 		}
157 157
 
158
-		$potf = '-' == $pot_filename? STDOUT : @fopen($pot_filename, 'a');
158
+		$potf = '-' == $pot_filename ? STDOUT : @fopen($pot_filename, 'a');
159 159
 		if (false === $potf) {
160 160
 			$this->cli_die("Couldn't open pot file: $pot_filename");
161 161
 		}
162 162
 
163
-		foreach($GLOBALS[$global_name] as $item) {
163
+		foreach ($GLOBALS[$global_name] as $item) {
164 164
 			@list($string, $comment_id, $filename, $line_number) = $item;
165
-			$filename = isset($filename)? preg_replace('|^\./|', '', $filename) : '';
166
-			$ref_line_number = isset($line_number)? ":$line_number" : '';
165
+			$filename = isset($filename) ? preg_replace('|^\./|', '', $filename) : '';
166
+			$ref_line_number = isset($line_number) ? ":$line_number" : '';
167 167
 			$args = array(
168 168
 				'singular' => $string,
169 169
 				'extracted_comments' => "Not gettexted string $comment_id",
@@ -192,9 +192,9 @@  discard block
 block discarded – undo
192 192
 		if (false === $res) {
193 193
 			$this->cli_die("Couldn't read MO file '$mo_filename'!");
194 194
 		}
195
-		foreach($filenames as $filename) {
195
+		foreach ($filenames as $filename) {
196 196
 			$source = file_get_contents($filename);
197
-			if ( strlen($source) > 150000 ) continue;
197
+			if (strlen($source) > 150000) continue;
198 198
 			$tokens = token_get_all($source);
199 199
 			$new_file = $this->walk_tokens($tokens, $replacer, array($this, 'unchanged_token'));
200 200
 			$f = fopen($filename, 'w');
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 
215 215
 	function cli() {
216 216
 		global $argv, $commands;
217
-		if (count($argv) < 4 || !in_array($argv[1], array_keys($this->commands))) {
217
+		if (count($argv) < 4 || ! in_array($argv[1], array_keys($this->commands))) {
218 218
 			$this->usage();
219 219
 			exit(1);
220 220
 		}
Please login to merge, or discard this patch.
tools/i18n/t/ExtractTest.php 1 patch
Spacing   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-require_once dirname( dirname( __FILE__ ) ) . '/extract.php';
3
+require_once dirname(dirname(__FILE__)).'/extract.php';
4 4
 
5 5
 class ExtractTest extends PHPUnit_Framework_TestCase {
6 6
 
@@ -12,126 +12,126 @@  discard block
 block discarded – undo
12 12
 	}
13 13
 
14 14
 	function test_with_just_a_string() {
15
-		$expected = new Translation_Entry( array( 'singular' => 'baba', 'references' => array('baba.php:1') ) );
16
-		$result = $this->extractor->extract_from_code('<?php __("baba"); ?>', 'baba.php' );
17
-		$this->assertEquals( $expected, $result->entries['baba'] );
15
+		$expected = new Translation_Entry(array('singular' => 'baba', 'references' => array('baba.php:1')));
16
+		$result = $this->extractor->extract_from_code('<?php __("baba"); ?>', 'baba.php');
17
+		$this->assertEquals($expected, $result->entries['baba']);
18 18
 	}
19 19
 
20 20
 	function test_entry_from_call_simple() {
21
-		$entry = $this->extractor->entry_from_call( array( 'name' => '__', 'args' => array('baba') ), 'baba.php' );
22
-		$this->assertEquals( $entry, new Translation_Entry( array( 'singular' => 'baba' ) ) );
21
+		$entry = $this->extractor->entry_from_call(array('name' => '__', 'args' => array('baba')), 'baba.php');
22
+		$this->assertEquals($entry, new Translation_Entry(array('singular' => 'baba')));
23 23
 	}
24 24
 
25 25
 	function test_entry_from_call_nonexisting_function() {
26
-		$entry = $this->extractor->entry_from_call( array( 'name' => 'f', 'args' => array('baba') ), 'baba.php' );
27
-		$this->assertEquals( $entry, null );
26
+		$entry = $this->extractor->entry_from_call(array('name' => 'f', 'args' => array('baba')), 'baba.php');
27
+		$this->assertEquals($entry, null);
28 28
 	}
29 29
 
30 30
 	function test_entry_from_call_too_few_args() {
31
-		$entry = $this->extractor->entry_from_call( array( 'name' => '__', 'args' => array() ), 'baba.php' );
32
-		$this->assertEquals( $entry, null );
31
+		$entry = $this->extractor->entry_from_call(array('name' => '__', 'args' => array()), 'baba.php');
32
+		$this->assertEquals($entry, null);
33 33
 	}
34 34
 
35 35
 	function test_entry_from_call_non_expected_null_arg() {
36
-		$this->extractor->rules = array( '_nx' => array( 'singular', 'plural', 'context' ) );
37
-		$entry = $this->extractor->entry_from_call( array( 'name' => '_nx', 'args' => array('%s baba', null, 'noun') ), 'baba.php' );
38
-		$this->assertEquals( $entry, null );
36
+		$this->extractor->rules = array('_nx' => array('singular', 'plural', 'context'));
37
+		$entry = $this->extractor->entry_from_call(array('name' => '_nx', 'args' => array('%s baba', null, 'noun')), 'baba.php');
38
+		$this->assertEquals($entry, null);
39 39
 	}
40 40
 
41 41
 	function test_entry_from_call_more_args_should_be_ok() {
42
-		$this->extractor->rules = array( '__' => array('string') );
43
-		$entry = $this->extractor->entry_from_call( array( 'name' => '__', 'args' => array('baba', 5, 'pijo', null) ), 'baba.php' );
44
-		$this->assertEquals( $entry, new Translation_Entry( array( 'singular' => 'baba' ) ) );
42
+		$this->extractor->rules = array('__' => array('string'));
43
+		$entry = $this->extractor->entry_from_call(array('name' => '__', 'args' => array('baba', 5, 'pijo', null)), 'baba.php');
44
+		$this->assertEquals($entry, new Translation_Entry(array('singular' => 'baba')));
45 45
 	}
46 46
 
47 47
 
48 48
 	function test_entry_from_call_context() {
49
-		$this->extractor->rules = array( '_x' => array( 'string', 'context' ) );
50
-		$entry = $this->extractor->entry_from_call( array( 'name' => '_x', 'args' => array('baba', 'noun') ), 'baba.php' );
51
-		$this->assertEquals( $entry, new Translation_Entry( array( 'singular' => 'baba', 'context' => 'noun' ) ) );
49
+		$this->extractor->rules = array('_x' => array('string', 'context'));
50
+		$entry = $this->extractor->entry_from_call(array('name' => '_x', 'args' => array('baba', 'noun')), 'baba.php');
51
+		$this->assertEquals($entry, new Translation_Entry(array('singular' => 'baba', 'context' => 'noun')));
52 52
 	}
53 53
 
54 54
 	function test_entry_from_call_plural() {
55
-		$this->extractor->rules = array( '_n' => array( 'singular', 'plural' ) );
56
-		$entry = $this->extractor->entry_from_call( array( 'name' => '_n', 'args' => array('%s baba', '%s babas') ), 'baba.php' );
57
-		$this->assertEquals( $entry, new Translation_Entry( array( 'singular' => '%s baba', 'plural' => '%s babas' ) ) );
55
+		$this->extractor->rules = array('_n' => array('singular', 'plural'));
56
+		$entry = $this->extractor->entry_from_call(array('name' => '_n', 'args' => array('%s baba', '%s babas')), 'baba.php');
57
+		$this->assertEquals($entry, new Translation_Entry(array('singular' => '%s baba', 'plural' => '%s babas')));
58 58
 	}
59 59
 
60 60
 	function test_entry_from_call_plural_and_context() {
61
-		$this->extractor->rules = array( '_nx' => array( 'singular', 'plural', 'context' ) );
62
-		$entry = $this->extractor->entry_from_call( array( 'name' => '_nx', 'args' => array('%s baba', '%s babas', 'noun') ), 'baba.php' );
63
-		$this->assertEquals( $entry, new Translation_Entry( array( 'singular' => '%s baba', 'plural' => '%s babas', 'context' => 'noun' ) ) );
61
+		$this->extractor->rules = array('_nx' => array('singular', 'plural', 'context'));
62
+		$entry = $this->extractor->entry_from_call(array('name' => '_nx', 'args' => array('%s baba', '%s babas', 'noun')), 'baba.php');
63
+		$this->assertEquals($entry, new Translation_Entry(array('singular' => '%s baba', 'plural' => '%s babas', 'context' => 'noun')));
64 64
 	}
65 65
 
66 66
 	function test_entry_from_call_extracted_comment() {
67
-		$entry = $this->extractor->entry_from_call( array( 'name' => '__', 'args' => array('baba'), 'comment' => 'translators: give me back my pants!' ), 'baba.php' );
68
-		$this->assertEquals( $entry, new Translation_Entry( array( 'singular' => 'baba', 'extracted_comments' => "translators: give me back my pants!\n" ) ) );
67
+		$entry = $this->extractor->entry_from_call(array('name' => '__', 'args' => array('baba'), 'comment' => 'translators: give me back my pants!'), 'baba.php');
68
+		$this->assertEquals($entry, new Translation_Entry(array('singular' => 'baba', 'extracted_comments' => "translators: give me back my pants!\n")));
69 69
 	}
70 70
 
71 71
 	function test_entry_from_call_line_number() {
72
-		$entry = $this->extractor->entry_from_call( array( 'name' => '__', 'args' => array('baba'), 'line' => 10 ), 'baba.php' );
73
-		$this->assertEquals( $entry, new Translation_Entry( array( 'singular' => 'baba', 'references' => array('baba.php:10') ) ) );
72
+		$entry = $this->extractor->entry_from_call(array('name' => '__', 'args' => array('baba'), 'line' => 10), 'baba.php');
73
+		$this->assertEquals($entry, new Translation_Entry(array('singular' => 'baba', 'references' => array('baba.php:10'))));
74 74
 	}
75 75
 
76 76
 	function test_entry_from_call_zero() {
77
-		$entry = $this->extractor->entry_from_call( array( 'name' => '__', 'args' => array('0') ), 'baba.php' );
78
-		$this->assertEquals( $entry, new Translation_Entry( array( 'singular' => '0' ) ) );
77
+		$entry = $this->extractor->entry_from_call(array('name' => '__', 'args' => array('0')), 'baba.php');
78
+		$this->assertEquals($entry, new Translation_Entry(array('singular' => '0')));
79 79
 	}
80 80
 
81 81
 	function test_entry_from_call_multiple() {
82
-		$this->extractor->rules = array( 'c' => array( 'string', 'singular', 'plural' ) );
83
-		$entries = $this->extractor->entry_from_call( array( 'name' => 'c', 'args' => array('baba', 'dyado', 'dyados') ), 'baba.php' );
84
-		$this->assertEquals( array(
85
-				new Translation_Entry( array( 'singular' => 'baba' ) ), new Translation_Entry( array( 'singular' => 'dyado', 'plural' => 'dyados' ) ) ), $entries );
82
+		$this->extractor->rules = array('c' => array('string', 'singular', 'plural'));
83
+		$entries = $this->extractor->entry_from_call(array('name' => 'c', 'args' => array('baba', 'dyado', 'dyados')), 'baba.php');
84
+		$this->assertEquals(array(
85
+				new Translation_Entry(array('singular' => 'baba')), new Translation_Entry(array('singular' => 'dyado', 'plural' => 'dyados')) ), $entries);
86 86
 	}
87 87
 
88 88
 	function test_entry_from_call_multiple_first_plural_then_two_strings() {
89
-		$this->extractor->rules = array( 'c' => array( 'singular', 'plural', null, 'string', 'string' ) );
90
-		$entries = $this->extractor->entry_from_call( array( 'name' => 'c', 'args' => array('dyado', 'dyados', 'baba', 'foo', 'bar') ), 'baba.php' );
91
-		$this->assertEquals( array(
92
-				new Translation_Entry( array( 'singular' => 'dyado', 'plural' => 'dyados' ) ),
93
-				new Translation_Entry( array( 'singular' => 'foo' ) ),
94
-				new Translation_Entry( array( 'singular' => 'bar' ) ) ), $entries );
89
+		$this->extractor->rules = array('c' => array('singular', 'plural', null, 'string', 'string'));
90
+		$entries = $this->extractor->entry_from_call(array('name' => 'c', 'args' => array('dyado', 'dyados', 'baba', 'foo', 'bar')), 'baba.php');
91
+		$this->assertEquals(array(
92
+				new Translation_Entry(array('singular' => 'dyado', 'plural' => 'dyados')),
93
+				new Translation_Entry(array('singular' => 'foo')),
94
+				new Translation_Entry(array('singular' => 'bar')) ), $entries);
95 95
 	}
96 96
 
97 97
 	function test_find_function_calls_one_arg_literal() {
98
-		$this->assertEquals( array( array( 'name' => '__', 'args' => array( 'baba' ), 'line' => 1 ) ), $this->extractor->find_function_calls( array('__'), '<?php __("baba"); ?>' ) );
98
+		$this->assertEquals(array(array('name' => '__', 'args' => array('baba'), 'line' => 1)), $this->extractor->find_function_calls(array('__'), '<?php __("baba"); ?>'));
99 99
 	}
100 100
 
101 101
 	function test_find_function_calls_one_arg_zero() {
102
-		$this->assertEquals( array( array( 'name' => '__', 'args' => array( '0' ), 'line' => 1 ) ), $this->extractor->find_function_calls( array('__'), '<?php __("0"); ?>' ) );
102
+		$this->assertEquals(array(array('name' => '__', 'args' => array('0'), 'line' => 1)), $this->extractor->find_function_calls(array('__'), '<?php __("0"); ?>'));
103 103
 	}
104 104
 
105 105
 	function test_find_function_calls_one_arg_non_literal() {
106
-		$this->assertEquals( array( array( 'name' => '__', 'args' => array( null ), 'line' => 1 ) ), $this->extractor->find_function_calls( array('__'), '<?php __("baba" . "dudu"); ?>' ) );
106
+		$this->assertEquals(array(array('name' => '__', 'args' => array(null), 'line' => 1)), $this->extractor->find_function_calls(array('__'), '<?php __("baba" . "dudu"); ?>'));
107 107
 	}
108 108
 
109 109
 	function test_find_function_calls_shouldnt_be_mistaken_by_a_class() {
110
-		$this->assertEquals( array(), $this->extractor->find_function_calls( array('__'), '<?php class __ { }; ("dyado");' ) );
110
+		$this->assertEquals(array(), $this->extractor->find_function_calls(array('__'), '<?php class __ { }; ("dyado");'));
111 111
 	}
112 112
 
113 113
 	function test_find_function_calls_2_args_bad_literal() {
114
-		$this->assertEquals( array( array( 'name' => 'f', 'args' => array( null, "baba" ), 'line' => 1 ) ), $this->extractor->find_function_calls( array('f'), '<?php f(5, "baba" ); ' ) );
114
+		$this->assertEquals(array(array('name' => 'f', 'args' => array(null, "baba"), 'line' => 1)), $this->extractor->find_function_calls(array('f'), '<?php f(5, "baba" ); '));
115 115
 	}
116 116
 
117 117
 	function test_find_function_calls_2_args_bad_literal_bad() {
118
-		$this->assertEquals( array( array( 'name' => 'f', 'args' => array( null, "baba", null ), 'line' => 1 ) ), $this->extractor->find_function_calls( array('f'), '<?php f(5, "baba", 5 ); ' ) );
118
+		$this->assertEquals(array(array('name' => 'f', 'args' => array(null, "baba", null), 'line' => 1)), $this->extractor->find_function_calls(array('f'), '<?php f(5, "baba", 5 ); '));
119 119
 	}
120 120
 
121 121
 	function test_find_function_calls_1_arg_bad_concat() {
122
-		$this->assertEquals( array( array( 'name' => 'f', 'args' => array( null ), 'line' => 1 ) ), $this->extractor->find_function_calls( array('f'), '<?php f( "baba" . "baba" ); ' ) );
122
+		$this->assertEquals(array(array('name' => 'f', 'args' => array(null), 'line' => 1)), $this->extractor->find_function_calls(array('f'), '<?php f( "baba" . "baba" ); '));
123 123
 	}
124 124
 
125 125
 	function test_find_function_calls_1_arg_bad_function_call() {
126
-		$this->assertEquals( array( array( 'name' => 'f', 'args' => array( null ), 'line' => 1 ) ), $this->extractor->find_function_calls( array('f'), '<?php f( g( "baba" ) ); ' ) );
126
+		$this->assertEquals(array(array('name' => 'f', 'args' => array(null), 'line' => 1)), $this->extractor->find_function_calls(array('f'), '<?php f( g( "baba" ) ); '));
127 127
 	}
128 128
 
129 129
 	function test_find_function_calls_2_arg_literal_bad() {
130
-		$this->assertEquals( array( array( 'name' => 'f', 'args' => array( "baba", null ), 'line' => 1 ) ), $this->extractor->find_function_calls( array('f'), '<?php f( "baba", null ); ' ) );
130
+		$this->assertEquals(array(array('name' => 'f', 'args' => array("baba", null), 'line' => 1)), $this->extractor->find_function_calls(array('f'), '<?php f( "baba", null ); '));
131 131
 	}
132 132
 
133 133
 	function test_find_function_calls_2_arg_bad_with_parens_literal() {
134
-		$this->assertEquals( array( array( 'name' => 'f', 'args' => array( null, "baba" ), 'line' => 1 ) ), $this->extractor->find_function_calls( array('f'), '<?php f( g( "dyado", "chicho", "lelya "), "baba" ); ' ) );
134
+		$this->assertEquals(array(array('name' => 'f', 'args' => array(null, "baba"), 'line' => 1)), $this->extractor->find_function_calls(array('f'), '<?php f( g( "dyado", "chicho", "lelya "), "baba" ); '));
135 135
 	}
136 136
 
137 137
 	/**
@@ -139,8 +139,8 @@  discard block
 block discarded – undo
139 139
 	 */
140 140
 	function test_find_function_calls_with_comment() {
141 141
 		$this->assertEquals(
142
-			array( array( 'name' => 'f', 'args' => array( 'baba' ), 'line' => 1, 'comment' => 'translators: let your ears fly!' ) ),
143
-			$this->extractor->find_function_calls( array('f'), '<?php /* translators: let your ears fly! */ f( "baba" ); ' )
142
+			array(array('name' => 'f', 'args' => array('baba'), 'line' => 1, 'comment' => 'translators: let your ears fly!')),
143
+			$this->extractor->find_function_calls(array('f'), '<?php /* translators: let your ears fly! */ f( "baba" ); ')
144 144
 		);
145 145
 	}
146 146
 
@@ -149,8 +149,8 @@  discard block
 block discarded – undo
149 149
 	 */
150 150
 	function test_find_function_calls_with_not_immediate_comment() {
151 151
 		$this->assertEquals(
152
-			array( array( 'name' => 'f', 'args' => array( 'baba' ), 'line' => 1, 'comment' => 'translators: let your ears fly!' ) ),
153
-			$this->extractor->find_function_calls( array('f'), '<?php /* translators: let your ears fly! */ $foo = g ( f( "baba" ) ); ' )
152
+			array(array('name' => 'f', 'args' => array('baba'), 'line' => 1, 'comment' => 'translators: let your ears fly!')),
153
+			$this->extractor->find_function_calls(array('f'), '<?php /* translators: let your ears fly! */ $foo = g ( f( "baba" ) ); ')
154 154
 		);
155 155
 	}
156 156
 
@@ -159,8 +159,8 @@  discard block
 block discarded – undo
159 159
 	 */
160 160
 	function test_find_function_calls_with_not_immediate_comment_include_only_latest() {
161 161
 		$this->assertEquals(
162
-			array( array( 'name' => 'f', 'args' => array( 'baba' ), 'line' => 1, 'comment' => 'translators: let your ears fly!' ) ),
163
-			$this->extractor->find_function_calls( array('f'), '<?php /* translators: boo */ /* translators: let your ears fly! */ /* baba */ $foo = g ( f( "baba" ) ); ' )
162
+			array(array('name' => 'f', 'args' => array('baba'), 'line' => 1, 'comment' => 'translators: let your ears fly!')),
163
+			$this->extractor->find_function_calls(array('f'), '<?php /* translators: boo */ /* translators: let your ears fly! */ /* baba */ $foo = g ( f( "baba" ) ); ')
164 164
 		);
165 165
 	}
166 166
 
@@ -168,11 +168,11 @@  discard block
 block discarded – undo
168 168
 	 * @group comment
169 169
 	 */
170 170
 	function test_find_function_calls_with_multi_line_comment() {
171
-		$this->assertEquals( array( array(
172
-				'name' => '__', 'args' => array( 'on' ), 'line' => 6,
171
+		$this->assertEquals(array(array(
172
+				'name' => '__', 'args' => array('on'), 'line' => 6,
173 173
 				'comment' => "Translators: If there are characters in your language that are not supported by Lato, translate this to 'off'. Do not translate into your own language."
174
-			) ),
175
-			$this->extractor->find_function_calls( array( '__' ),
174
+			)),
175
+			$this->extractor->find_function_calls(array('__'),
176 176
 				"<?php
177 177
 				/*
178 178
 				 * Translators: If there are characters in your language that are not supported
@@ -188,8 +188,8 @@  discard block
 block discarded – undo
188 188
 	 */
189 189
 	function test_comment_prefix_should_be_case_insensitive() {
190 190
 		$this->assertEquals(
191
-			array( array( 'name' => 'f', 'args' => array( 'baba' ), 'line' => 1, 'comment' => 'Translators: let your ears fly!' ) ),
192
-			$this->extractor->find_function_calls( array('f'), '<?php /* Translators: let your ears fly! */ f( "baba" ); ' )
191
+			array(array('name' => 'f', 'args' => array('baba'), 'line' => 1, 'comment' => 'Translators: let your ears fly!')),
192
+			$this->extractor->find_function_calls(array('f'), '<?php /* Translators: let your ears fly! */ f( "baba" ); ')
193 193
 		);
194 194
 	}
195 195
 }
Please login to merge, or discard this patch.
tools/i18n/t/data/not-gettexted-0-result.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,23 +1,23 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (! isset($wp_did_header)):
4
-if ( !file_exists( dirname(__FILE__) . '/wp-config.php') ) {
3
+if ( ! isset($wp_did_header)):
4
+if ( ! file_exists(dirname(__FILE__).'/wp-config.php')) {
5 5
 	if (strpos($_SERVER['PHP_SELF'], 'wp-admin') !== false) $path = '';
6 6
 	else $path = 'wp-admin/';
7 7
 
8
-	require_once( dirname(__FILE__) . '/wp-includes/classes.php');
9
-	require_once( dirname(__FILE__) . '/wp-includes/functions.php');
10
-	require_once( dirname(__FILE__) . '/wp-includes/plugin.php');
11
-	wp_die( sprintf(/*WP_I18N_CONFIG*/'Translation: There doesn\'t seem to be a <code>wp-config.php</code> file. I need this before we can get started. Need more help? <a href=\'http://codex.wordpress.org/Editing_wp-config.php\'>We got it</a>. You can create a <code>wp-config.php</code> file through a web interface, but this doesn\'t work for all server setups. The safest way is to manually create the file.</p><p><a href=\'%s\' class=\'button\'>Create a Configuration File</a>' /*/WP_I18N_CONFIG*/, $path.'setup-config.php'), /*WP_I18N_ERROR*/ 'Translation: WordPress &rsaquo; Error' /*/WP_I18N_ERROR*/);
8
+	require_once(dirname(__FILE__).'/wp-includes/classes.php');
9
+	require_once(dirname(__FILE__).'/wp-includes/functions.php');
10
+	require_once(dirname(__FILE__).'/wp-includes/plugin.php');
11
+	wp_die(sprintf(/*WP_I18N_CONFIG*/'Translation: There doesn\'t seem to be a <code>wp-config.php</code> file. I need this before we can get started. Need more help? <a href=\'http://codex.wordpress.org/Editing_wp-config.php\'>We got it</a>. You can create a <code>wp-config.php</code> file through a web interface, but this doesn\'t work for all server setups. The safest way is to manually create the file.</p><p><a href=\'%s\' class=\'button\'>Create a Configuration File</a>' /*/WP_I18N_CONFIG*/, $path.'setup-config.php'), /*WP_I18N_ERROR*/ 'Translation: WordPress &rsaquo; Error' /*/WP_I18N_ERROR*/);
12 12
 }
13 13
 
14 14
 $wp_did_header = true;
15 15
 
16
-require_once( dirname(__FILE__) . '/wp-config.php');
16
+require_once(dirname(__FILE__).'/wp-config.php');
17 17
 
18 18
 wp();
19 19
 
20
-require_once(ABSPATH . WPINC . '/template-loader.php');
20
+require_once(ABSPATH.WPINC.'/template-loader.php');
21 21
 
22 22
 endif;
23 23
 
Please login to merge, or discard this patch.
tools/i18n/t/data/not-gettexted-0.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,23 +1,23 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (! isset($wp_did_header)):
4
-if ( !file_exists( dirname(__FILE__) . '/wp-config.php') ) {
3
+if ( ! isset($wp_did_header)):
4
+if ( ! file_exists(dirname(__FILE__).'/wp-config.php')) {
5 5
 	if (strpos($_SERVER['PHP_SELF'], 'wp-admin') !== false) $path = '';
6 6
 	else $path = 'wp-admin/';
7 7
 
8
-	require_once( dirname(__FILE__) . '/wp-includes/classes.php');
9
-	require_once( dirname(__FILE__) . '/wp-includes/functions.php');
10
-	require_once( dirname(__FILE__) . '/wp-includes/plugin.php');
11
-	wp_die( sprintf(/*WP_I18N_CONFIG*/" There doesn't seem to be a <code>wp-config.php</code> file. I need this before we can get started. Need more help? <a href='http://codex.wordpress.org/Editing_wp-config.php'>We got it</a>. You can create a <code>wp-config.php</code> file through a web interface, but this doesn't work for all server setups. The safest way is to manually create the file.</p><p><a href='%s' class='button'>Create a Configuration File</a>" /*/WP_I18N_CONFIG*/, $path.'setup-config.php'), /*WP_I18N_ERROR*/ "WordPress &rsaquo; Error" /*/WP_I18N_ERROR*/);
8
+	require_once(dirname(__FILE__).'/wp-includes/classes.php');
9
+	require_once(dirname(__FILE__).'/wp-includes/functions.php');
10
+	require_once(dirname(__FILE__).'/wp-includes/plugin.php');
11
+	wp_die(sprintf(/*WP_I18N_CONFIG*/" There doesn't seem to be a <code>wp-config.php</code> file. I need this before we can get started. Need more help? <a href='http://codex.wordpress.org/Editing_wp-config.php'>We got it</a>. You can create a <code>wp-config.php</code> file through a web interface, but this doesn't work for all server setups. The safest way is to manually create the file.</p><p><a href='%s' class='button'>Create a Configuration File</a>" /*/WP_I18N_CONFIG*/, $path.'setup-config.php'), /*WP_I18N_ERROR*/ "WordPress &rsaquo; Error" /*/WP_I18N_ERROR*/);
12 12
 }
13 13
 
14 14
 $wp_did_header = true;
15 15
 
16
-require_once( dirname(__FILE__) . '/wp-config.php');
16
+require_once(dirname(__FILE__).'/wp-config.php');
17 17
 
18 18
 wp();
19 19
 
20
-require_once(ABSPATH . WPINC . '/template-loader.php');
20
+require_once(ABSPATH.WPINC.'/template-loader.php');
21 21
 
22 22
 endif;
23 23
 
Please login to merge, or discard this patch.
tools/i18n/t/NotGettextedTest.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -5,8 +5,8 @@  discard block
 block discarded – undo
5 5
  * @package wordpress-i18n
6 6
  * @subpackage tools
7 7
  */
8
-error_reporting( E_ALL );
9
-require_once dirname( dirname( __FILE__ ) ) . '/not-gettexted.php';
8
+error_reporting(E_ALL);
9
+require_once dirname(dirname(__FILE__)).'/not-gettexted.php';
10 10
 
11 11
 class NotGettextedTest extends PHPUnit_Framework_TestCase {
12 12
 
@@ -16,10 +16,10 @@  discard block
 block discarded – undo
16 16
 
17 17
 	function test_make_string_aggregator() {
18 18
 		global $baba;
19
-		$f = $this->ng->make_string_aggregator( 'baba', 'baba.php' );
20
-		call_user_func( $f, 'x', 'y', 'z' );
21
-		call_user_func( $f, 'a', 'b', 'c' );
22
-		$this->assertEquals( array( array( 'x', 'y', 'baba.php', 'z'), array( 'a', 'b', 'baba.php', 'c' ) ), $baba );
19
+		$f = $this->ng->make_string_aggregator('baba', 'baba.php');
20
+		call_user_func($f, 'x', 'y', 'z');
21
+		call_user_func($f, 'a', 'b', 'c');
22
+		$this->assertEquals(array(array('x', 'y', 'baba.php', 'z'), array('a', 'b', 'baba.php', 'c')), $baba);
23 23
 	}
24 24
 
25 25
 	function test_walk() {
@@ -30,17 +30,17 @@  discard block
 block discarded – undo
30 30
 	if ($x == "18181") { wp_die(sprintf(/*WP_I18N_DIE*/\'We died %d times!\'/*WP_I18N_DIE*/)); }
31 31
 ?>';
32 32
 		$tokens = token_get_all($code);
33
-		$this->assertEquals( '', $this->ng->walk_tokens( $tokens, array($this->ng, 'ignore_token'), array($this->ng, 'ignore_token') ) );
34
-		$this->assertEquals( '"yes"\'We died %d times!\'', $this->ng->walk_tokens( $tokens, array($this->ng, 'unchanged_token'), array($this->ng, 'ignore_token') ) );
35
-		$this->assertEquals( $code, $this->ng->walk_tokens( $tokens, array($this->ng, 'unchanged_token'), array($this->ng, 'unchanged_token') ) );
36
-		$this->assertEquals( $code, $this->ng->walk_tokens( $tokens, array($this->ng, 'unchanged_token'), array($this->ng, 'unchanged_token') ) );
33
+		$this->assertEquals('', $this->ng->walk_tokens($tokens, array($this->ng, 'ignore_token'), array($this->ng, 'ignore_token')));
34
+		$this->assertEquals('"yes"\'We died %d times!\'', $this->ng->walk_tokens($tokens, array($this->ng, 'unchanged_token'), array($this->ng, 'ignore_token')));
35
+		$this->assertEquals($code, $this->ng->walk_tokens($tokens, array($this->ng, 'unchanged_token'), array($this->ng, 'unchanged_token')));
36
+		$this->assertEquals($code, $this->ng->walk_tokens($tokens, array($this->ng, 'unchanged_token'), array($this->ng, 'unchanged_token')));
37 37
 	}
38 38
 
39 39
 	function test_replace() {
40 40
 		# copy to a new file, so that we don't corrupt the old one
41
-		copy( 'data/not-gettexted-0.php', 'data/not-gettexted-0-work.php' );
42
-		$this->ng->command_replace( 'data/not-gettexted-0.mo', 'data/not-gettexted-0-work.php' );
43
-		$this->assertEquals( file_get_contents( 'data/not-gettexted-0-result.php' ), file_get_contents( 'data/not-gettexted-0-work.php' ) );
44
-		unlink( 'data/not-gettexted-0-work.php' );
41
+		copy('data/not-gettexted-0.php', 'data/not-gettexted-0-work.php');
42
+		$this->ng->command_replace('data/not-gettexted-0.mo', 'data/not-gettexted-0-work.php');
43
+		$this->assertEquals(file_get_contents('data/not-gettexted-0-result.php'), file_get_contents('data/not-gettexted-0-work.php'));
44
+		unlink('data/not-gettexted-0-work.php');
45 45
 	}
46 46
 }
Please login to merge, or discard this patch.
tools/i18n/add-textdomain.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  */
8 8
 error_reporting(E_ALL);
9 9
 
10
-require_once dirname( __FILE__ ) . '/makepot.php';
10
+require_once dirname(__FILE__).'/makepot.php';
11 11
 
12 12
 class AddTextdomain {
13 13
 
@@ -19,14 +19,14 @@  discard block
 block discarded – undo
19 19
 	 */
20 20
 	function __construct() {
21 21
 		$makepot = new MakePOT;
22
-		$this->funcs = array_keys( $makepot->rules );
22
+		$this->funcs = array_keys($makepot->rules);
23 23
 	}
24 24
 
25 25
 	/**
26 26
 	 * PHP4 constructor.
27 27
 	 */
28 28
 	public function AddTextdomain() {
29
-		_deprecated_constructor( 'AddTextdomain' , '4.3'  );
29
+		_deprecated_constructor('AddTextdomain', '4.3');
30 30
 	}
31 31
 
32 32
 	function usage() {
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 		$parens_balance = 0;
57 57
 		$found_domain = false;
58 58
 
59
-		foreach($tokens as $token) {
59
+		foreach ($tokens as $token) {
60 60
 			$string_success = false;
61 61
 			if (is_array($token)) {
62 62
 				list($id, $text) = $token;
@@ -71,13 +71,13 @@  discard block
 block discarded – undo
71 71
 					}
72 72
 				}
73 73
 				$token = $text;
74
-			} elseif ('(' == $token){
74
+			} elseif ('(' == $token) {
75 75
 				$args_started = true;
76 76
 				++$parens_balance;
77 77
 			} elseif (')' == $token) {
78 78
 				--$parens_balance;
79 79
 				if ($in_func && 0 == $parens_balance) {
80
-					$token = $found_domain? ')' : ", '$domain')";
80
+					$token = $found_domain ? ')' : ", '$domain')";
81 81
 					$in_func = false;
82 82
 					$args_started = false;
83 83
 					$found_domain = false;
@@ -101,14 +101,14 @@  discard block
 block discarded – undo
101 101
 if ($included_files[0] == __FILE__) {
102 102
 	$adddomain = new AddTextdomain;
103 103
 
104
-	if (!isset($argv[1]) || !isset($argv[2])) {
104
+	if ( ! isset($argv[1]) || ! isset($argv[2])) {
105 105
 		$adddomain->usage();
106 106
 	}
107 107
 
108 108
 	$inplace = false;
109 109
 	if ('-i' == $argv[1]) {
110 110
 		$inplace = true;
111
-		if (!isset($argv[3])) $adddomain->usage();
111
+		if ( ! isset($argv[3])) $adddomain->usage();
112 112
 		array_shift($argv);	
113 113
 	}
114 114
 
Please login to merge, or discard this patch.
tools/i18n/makepot.php 1 patch
Spacing   +173 added lines, -173 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@  discard block
 block discarded – undo
1 1
 <?php
2
-require_once dirname( __FILE__ ) . '/not-gettexted.php';
3
-require_once dirname( __FILE__ ) . '/pot-ext-meta.php';
4
-require_once dirname( __FILE__ ) . '/extract.php';
2
+require_once dirname(__FILE__).'/not-gettexted.php';
3
+require_once dirname(__FILE__).'/pot-ext-meta.php';
4
+require_once dirname(__FILE__).'/extract.php';
5 5
 
6
-if ( !defined( 'STDERR' ) ) {
7
-	define( 'STDERR', fopen( 'php://stderr', 'w' ) );
6
+if ( ! defined('STDERR')) {
7
+	define('STDERR', fopen('php://stderr', 'w'));
8 8
 }
9 9
 
10 10
 class MakePOT {
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 		'comments_number_link' => array('string', 'singular', 'plural'),
54 54
 	);
55 55
 
56
-	var $ms_files = array( 'ms-.*', '.*/ms-.*', '.*/my-.*', 'wp-activate\.php', 'wp-signup\.php', 'wp-admin/network\.php', 'wp-admin/includes/ms\.php', 'wp-admin/network/.*\.php', 'wp-admin/includes/class-wp-ms.*' );
56
+	var $ms_files = array('ms-.*', '.*/ms-.*', '.*/my-.*', 'wp-activate\.php', 'wp-signup\.php', 'wp-admin/network\.php', 'wp-admin/includes/ms\.php', 'wp-admin/network/.*\.php', 'wp-admin/includes/class-wp-ms.*');
57 57
 
58 58
 	var $temp_files = array();
59 59
 
@@ -145,16 +145,16 @@  discard block
 block discarded – undo
145 145
 	);
146 146
 
147 147
 	function __construct($deprecated = true) {
148
-		$this->extractor = new StringExtractor( $this->rules );
148
+		$this->extractor = new StringExtractor($this->rules);
149 149
 	}
150 150
 
151 151
 	function __destruct() {
152
-		foreach ( $this->temp_files as $temp_file )
153
-			unlink( $temp_file );
152
+		foreach ($this->temp_files as $temp_file)
153
+			unlink($temp_file);
154 154
 	}
155 155
 
156
-	function tempnam( $file ) {
157
-		$tempnam = tempnam( sys_get_temp_dir(), $file );
156
+	function tempnam($file) {
157
+		$tempnam = tempnam(sys_get_temp_dir(), $file);
158 158
 		$this->temp_files[] = $tempnam;
159 159
 		return $tempnam;
160 160
 	}
@@ -164,31 +164,31 @@  discard block
 block discarded – undo
164 164
 	}
165 165
 
166 166
 	function xgettext($project, $dir, $output_file, $placeholders = array(), $excludes = array(), $includes = array()) {
167
-		$meta = array_merge( $this->meta['default'], $this->meta[$project] );
168
-		$placeholders = array_merge( $meta, $placeholders );
169
-		$meta['output'] = $this->realpath_missing( $output_file );
170
-		$placeholders['year'] = date( 'Y' );
171
-		$placeholder_keys = array_map( create_function( '$x', 'return "{".$x."}";' ), array_keys( $placeholders ) );
172
-		$placeholder_values = array_values( $placeholders );
173
-		foreach($meta as $key => $value) {
167
+		$meta = array_merge($this->meta['default'], $this->meta[$project]);
168
+		$placeholders = array_merge($meta, $placeholders);
169
+		$meta['output'] = $this->realpath_missing($output_file);
170
+		$placeholders['year'] = date('Y');
171
+		$placeholder_keys = array_map(create_function('$x', 'return "{".$x."}";'), array_keys($placeholders));
172
+		$placeholder_values = array_values($placeholders);
173
+		foreach ($meta as $key => $value) {
174 174
 			$meta[$key] = str_replace($placeholder_keys, $placeholder_values, $value);
175 175
 		}
176 176
 
177
-		$originals = $this->extractor->extract_from_directory( $dir, $excludes, $includes );
177
+		$originals = $this->extractor->extract_from_directory($dir, $excludes, $includes);
178 178
 		$pot = new PO;
179 179
 		$pot->entries = $originals->entries;
180 180
 
181
-		$pot->set_header( 'Project-Id-Version', $meta['package-name'].' '.$meta['package-version'] );
182
-		$pot->set_header( 'Report-Msgid-Bugs-To', $meta['msgid-bugs-address'] );
183
-		$pot->set_header( 'POT-Creation-Date', gmdate( 'Y-m-d H:i:s+00:00' ) );
184
-		$pot->set_header( 'MIME-Version', '1.0' );
185
-		$pot->set_header( 'Content-Type', 'text/plain; charset=UTF-8' );
186
-		$pot->set_header( 'Content-Transfer-Encoding', '8bit' );
187
-		$pot->set_header( 'PO-Revision-Date', date( 'Y') . '-MO-DA HO:MI+ZONE' );
188
-		$pot->set_header( 'Last-Translator', 'FULL NAME <EMAIL@ADDRESS>' );
189
-		$pot->set_header( 'Language-Team', 'LANGUAGE <[email protected]>' );
190
-		$pot->set_comment_before_headers( $meta['comments'] );
191
-		$pot->export_to_file( $output_file );
181
+		$pot->set_header('Project-Id-Version', $meta['package-name'].' '.$meta['package-version']);
182
+		$pot->set_header('Report-Msgid-Bugs-To', $meta['msgid-bugs-address']);
183
+		$pot->set_header('POT-Creation-Date', gmdate('Y-m-d H:i:s+00:00'));
184
+		$pot->set_header('MIME-Version', '1.0');
185
+		$pot->set_header('Content-Type', 'text/plain; charset=UTF-8');
186
+		$pot->set_header('Content-Transfer-Encoding', '8bit');
187
+		$pot->set_header('PO-Revision-Date', date('Y').'-MO-DA HO:MI+ZONE');
188
+		$pot->set_header('Last-Translator', 'FULL NAME <EMAIL@ADDRESS>');
189
+		$pot->set_header('Language-Team', 'LANGUAGE <[email protected]>');
190
+		$pot->set_comment_before_headers($meta['comments']);
191
+		$pot->export_to_file($output_file);
192 192
 		return true;
193 193
 	}
194 194
 
@@ -199,203 +199,203 @@  discard block
 block discarded – undo
199 199
 			'default_output' => 'wordpress.pot',
200 200
 			'includes' => array(),
201 201
 			'excludes' => array_merge(
202
-				array('wp-admin/includes/continents-cities\.php', 'wp-content/themes/twenty.*', ),
202
+				array('wp-admin/includes/continents-cities\.php', 'wp-content/themes/twenty.*',),
203 203
 				$this->ms_files
204 204
 			),
205 205
 			'extract_not_gettexted' => false,
206 206
 			'not_gettexted_files_filter' => false,
207 207
 		);
208
-		$args = array_merge( $defaults, $args );
209
-		extract( $args );
208
+		$args = array_merge($defaults, $args);
209
+		extract($args);
210 210
 		$placeholders = array();
211
-		if ( $wp_version = $this->wp_version( $dir ) )
211
+		if ($wp_version = $this->wp_version($dir))
212 212
 			$placeholders['version'] = $wp_version;
213 213
 		else
214 214
 			return false;
215
-		$output = is_null( $output )? $default_output : $output;
216
-		$res = $this->xgettext( $project, $dir, $output, $placeholders, $excludes, $includes );
217
-		if ( !$res ) return false;
215
+		$output = is_null($output) ? $default_output : $output;
216
+		$res = $this->xgettext($project, $dir, $output, $placeholders, $excludes, $includes);
217
+		if ( ! $res) return false;
218 218
 
219
-		if ( $extract_not_gettexted ) {
219
+		if ($extract_not_gettexted) {
220 220
 			$old_dir = getcwd();
221
-			$output = realpath( $output );
222
-			chdir( $dir );
221
+			$output = realpath($output);
222
+			chdir($dir);
223 223
 			$php_files = NotGettexted::list_php_files('.');
224
-			$php_files = array_filter( $php_files, $not_gettexted_files_filter );
224
+			$php_files = array_filter($php_files, $not_gettexted_files_filter);
225 225
 			$not_gettexted = new NotGettexted;
226
-			$res = $not_gettexted->command_extract( $output, $php_files );
227
-			chdir( $old_dir );
226
+			$res = $not_gettexted->command_extract($output, $php_files);
227
+			chdir($old_dir);
228 228
 			/* Adding non-gettexted strings can repeat some phrases */
229
-			$output_shell = escapeshellarg( $output );
230
-			system( "msguniq --use-first $output_shell -o $output_shell" );
229
+			$output_shell = escapeshellarg($output);
230
+			system("msguniq --use-first $output_shell -o $output_shell");
231 231
 		}
232 232
 		return $res;
233 233
 	}
234 234
 
235 235
 	function wp_core($dir, $output) {
236
-		if ( file_exists( "$dir/wp-admin/user/about.php" ) ) return false;
236
+		if (file_exists("$dir/wp-admin/user/about.php")) return false;
237 237
 
238
-		return $this->wp_generic( $dir, array(
238
+		return $this->wp_generic($dir, array(
239 239
 			'project' => 'wp-core', 'output' => $output,
240 240
 			'extract_not_gettexted' => true,
241
-			'not_gettexted_files_filter' => array( $this, 'is_not_ms_file' ),
242
-		) );
241
+			'not_gettexted_files_filter' => array($this, 'is_not_ms_file'),
242
+		));
243 243
 	}
244 244
 
245
-	function wp_frontend( $dir, $output ) {
246
-		if ( ! file_exists( "$dir/wp-admin/user/about.php" ) ) {
245
+	function wp_frontend($dir, $output) {
246
+		if ( ! file_exists("$dir/wp-admin/user/about.php")) {
247 247
 			return false;
248 248
 		}
249 249
 
250
-		$excludes = array( 'wp-admin/.*', 'wp-content/themes/.*', 'wp-includes/class-pop3\.php' );
250
+		$excludes = array('wp-admin/.*', 'wp-content/themes/.*', 'wp-includes/class-pop3\.php');
251 251
 
252 252
 		// Exclude Akismet all together for 3.9+.
253
-		if ( file_exists( "$dir/wp-admin/css/about.css" ) ) {
253
+		if (file_exists("$dir/wp-admin/css/about.css")) {
254 254
 			$excludes[] = 'wp-content/plugins/akismet/.*';
255 255
 		}
256 256
 
257
-		return $this->wp_generic( $dir, array(
257
+		return $this->wp_generic($dir, array(
258 258
 			'project' => 'wp-frontend', 'output' => $output,
259 259
 			'includes' => array(),
260 260
 			'excludes' => $excludes,
261 261
 			'default_output' => 'wordpress.pot',
262
-		) );
262
+		));
263 263
 	}
264 264
 
265 265
 	function wp_admin($dir, $output) {
266
-		if ( ! file_exists( "$dir/wp-admin/user/about.php" ) ) {
266
+		if ( ! file_exists("$dir/wp-admin/user/about.php")) {
267 267
 			return false;
268 268
 		}
269 269
 
270
-		$frontend_pot = $this->tempnam( 'frontend.pot' );
271
-		if ( false === $frontend_pot ) {
270
+		$frontend_pot = $this->tempnam('frontend.pot');
271
+		if (false === $frontend_pot) {
272 272
 			return false;
273 273
 		}
274 274
 
275
-		$frontend_result = $this->wp_frontend( $dir, $frontend_pot );
276
-		if ( ! $frontend_result ) {
275
+		$frontend_result = $this->wp_frontend($dir, $frontend_pot);
276
+		if ( ! $frontend_result) {
277 277
 			return false;
278 278
 		}
279 279
 
280
-		$result = $this->wp_generic( $dir, array(
280
+		$result = $this->wp_generic($dir, array(
281 281
 			'project' => 'wp-admin', 'output' => $output,
282
-			'includes' => array( 'wp-admin/.*' ),
283
-			'excludes' => array( 'wp-admin/includes/continents-cities\.php', 'wp-admin/network/.*', 'wp-admin/network.php' ),
282
+			'includes' => array('wp-admin/.*'),
283
+			'excludes' => array('wp-admin/includes/continents-cities\.php', 'wp-admin/network/.*', 'wp-admin/network.php'),
284 284
 			'default_output' => 'wordpress-admin.pot',
285
-		) );
286
-		if ( ! $result ) {
285
+		));
286
+		if ( ! $result) {
287 287
 			return false;
288 288
 		}
289 289
 
290 290
 		$potextmeta = new PotExtMeta;
291 291
 
292
-		if ( ! file_exists( "$dir/wp-admin/css/about.css" ) ) { // < 3.9
293
-			$result = $potextmeta->append( "$dir/wp-content/plugins/akismet/akismet.php", $output );
294
-			if ( ! $result ) {
292
+		if ( ! file_exists("$dir/wp-admin/css/about.css")) { // < 3.9
293
+			$result = $potextmeta->append("$dir/wp-content/plugins/akismet/akismet.php", $output);
294
+			if ( ! $result) {
295 295
 				return false;
296 296
 			}
297 297
 		}
298 298
 
299
-		$result = $potextmeta->append( "$dir/wp-content/plugins/hello.php", $output );
300
-		if ( ! $result ) {
299
+		$result = $potextmeta->append("$dir/wp-content/plugins/hello.php", $output);
300
+		if ( ! $result) {
301 301
 			return false;
302 302
 		}
303 303
 
304 304
 		/* Adding non-gettexted strings can repeat some phrases */
305
-		$output_shell = escapeshellarg( $output );
306
-		system( "msguniq $output_shell -o $output_shell" );
305
+		$output_shell = escapeshellarg($output);
306
+		system("msguniq $output_shell -o $output_shell");
307 307
 
308
-		$common_pot = $this->tempnam( 'common.pot' );
309
-		if ( ! $common_pot ) {
308
+		$common_pot = $this->tempnam('common.pot');
309
+		if ( ! $common_pot) {
310 310
 			return false;
311 311
 		}
312
-		$admin_pot = realpath( is_null( $output ) ? 'wordpress-admin.pot' : $output );
313
-		system( "msgcat --more-than=1 --use-first $frontend_pot $admin_pot > $common_pot" );
314
-		system( "msgcat -u --use-first $admin_pot $common_pot -o $admin_pot" );
312
+		$admin_pot = realpath(is_null($output) ? 'wordpress-admin.pot' : $output);
313
+		system("msgcat --more-than=1 --use-first $frontend_pot $admin_pot > $common_pot");
314
+		system("msgcat -u --use-first $admin_pot $common_pot -o $admin_pot");
315 315
 		return true;
316 316
 	}
317 317
 
318 318
 	function wp_network_admin($dir, $output) {
319
-		if ( ! file_exists( "$dir/wp-admin/user/about.php" ) ) return false;
319
+		if ( ! file_exists("$dir/wp-admin/user/about.php")) return false;
320 320
 
321
-		$frontend_pot = $this->tempnam( 'frontend.pot' );
322
-		if ( false === $frontend_pot ) return false;
321
+		$frontend_pot = $this->tempnam('frontend.pot');
322
+		if (false === $frontend_pot) return false;
323 323
 
324
-		$frontend_result = $this->wp_frontend( $dir, $frontend_pot );
325
-		if ( ! $frontend_result )
324
+		$frontend_result = $this->wp_frontend($dir, $frontend_pot);
325
+		if ( ! $frontend_result)
326 326
 			return false;
327 327
 
328
-		$admin_pot = $this->tempnam( 'admin.pot' );
329
-		if ( false === $admin_pot ) return false;
328
+		$admin_pot = $this->tempnam('admin.pot');
329
+		if (false === $admin_pot) return false;
330 330
 
331
-		$admin_result = $this->wp_admin( $dir, $admin_pot );
332
-		if ( ! $admin_result )
331
+		$admin_result = $this->wp_admin($dir, $admin_pot);
332
+		if ( ! $admin_result)
333 333
 			return false;
334 334
 
335
-		$result = $this->wp_generic( $dir, array(
335
+		$result = $this->wp_generic($dir, array(
336 336
 			'project' => 'wp-network-admin', 'output' => $output,
337
-			'includes' => array( 'wp-admin/network/.*', 'wp-admin/network.php' ),
337
+			'includes' => array('wp-admin/network/.*', 'wp-admin/network.php'),
338 338
 			'excludes' => array(),
339 339
 			'default_output' => 'wordpress-admin-network.pot',
340
-		) );
340
+		));
341 341
 
342
-		if ( ! $result ) {
342
+		if ( ! $result) {
343 343
 			return false;
344 344
 		}
345 345
 
346
-		$common_pot = $this->tempnam( 'common.pot' );
347
-		if ( ! $common_pot )
346
+		$common_pot = $this->tempnam('common.pot');
347
+		if ( ! $common_pot)
348 348
 			return false;
349 349
 
350
-		$net_admin_pot = realpath( is_null( $output ) ? 'wordpress-network-admin.pot' : $output );
351
-		system( "msgcat --more-than=1 --use-first $frontend_pot $admin_pot $net_admin_pot > $common_pot" );
352
-		system( "msgcat -u --use-first $net_admin_pot $common_pot -o $net_admin_pot" );
350
+		$net_admin_pot = realpath(is_null($output) ? 'wordpress-network-admin.pot' : $output);
351
+		system("msgcat --more-than=1 --use-first $frontend_pot $admin_pot $net_admin_pot > $common_pot");
352
+		system("msgcat -u --use-first $net_admin_pot $common_pot -o $net_admin_pot");
353 353
 		return true;
354 354
 	}
355 355
 
356 356
 	function wp_ms($dir, $output) {
357
-		if ( file_exists( "$dir/wp-admin/user/about.php" ) ) return false;
358
-		if ( !is_file("$dir/wp-admin/ms-users.php") ) return false;
359
-		$core_pot = $this->tempnam( 'wordpress.pot' );
360
-		if ( false === $core_pot ) return false;
361
-		$core_result = $this->wp_core( $dir, $core_pot );
362
-		if ( ! $core_result )
357
+		if (file_exists("$dir/wp-admin/user/about.php")) return false;
358
+		if ( ! is_file("$dir/wp-admin/ms-users.php")) return false;
359
+		$core_pot = $this->tempnam('wordpress.pot');
360
+		if (false === $core_pot) return false;
361
+		$core_result = $this->wp_core($dir, $core_pot);
362
+		if ( ! $core_result)
363 363
 			return false;
364
-		$ms_result = $this->wp_generic( $dir, array(
364
+		$ms_result = $this->wp_generic($dir, array(
365 365
 			'project' => 'wp-ms', 'output' => $output,
366 366
 			'includes' => $this->ms_files,
367 367
 			'excludes' => array(),
368 368
 			'default_output' => 'wordpress-ms.pot',
369 369
 			'extract_not_gettexted' => true,
370
-			'not_gettexted_files_filter' => array( $this, 'is_ms_file' ),
371
-		) );
372
-		if ( !$ms_result ) {
370
+			'not_gettexted_files_filter' => array($this, 'is_ms_file'),
371
+		));
372
+		if ( ! $ms_result) {
373 373
 			return false;
374 374
 		}
375
-		$common_pot = $this->tempnam( 'common.pot' );
376
-		if ( ! $common_pot )
375
+		$common_pot = $this->tempnam('common.pot');
376
+		if ( ! $common_pot)
377 377
 			return false;
378
-		$ms_pot = realpath( is_null( $output )? 'wordpress-ms.pot' : $output );
379
-		system( "msgcat --more-than=1 --use-first $core_pot $ms_pot > $common_pot" );
380
-		system( "msgcat -u --use-first $ms_pot $common_pot -o $ms_pot" );
378
+		$ms_pot = realpath(is_null($output) ? 'wordpress-ms.pot' : $output);
379
+		system("msgcat --more-than=1 --use-first $core_pot $ms_pot > $common_pot");
380
+		system("msgcat -u --use-first $ms_pot $common_pot -o $ms_pot");
381 381
 		return true;
382 382
 	}
383 383
 
384 384
 	function wp_tz($dir, $output) {
385 385
 		$continents_path = 'wp-admin/includes/continents-cities.php';
386
-		if ( !file_exists( "$dir/$continents_path" ) ) return false;
387
-		return $this->wp_generic( $dir, array(
386
+		if ( ! file_exists("$dir/$continents_path")) return false;
387
+		return $this->wp_generic($dir, array(
388 388
 			'project' => 'wp-tz', 'output' => $output,
389
-			'includes' => array( $continents_path ),
389
+			'includes' => array($continents_path),
390 390
 			'excludes' => array(),
391 391
 			'default_output' => 'wordpress-continents-cities.pot',
392
-		) );
392
+		));
393 393
 	}
394 394
 
395 395
 	function wp_version($dir) {
396 396
 		$version_php = $dir.'/wp-includes/version.php';
397
-		if ( !is_readable( $version_php ) ) return false;
398
-		return preg_match( '/\$wp_version\s*=\s*\'(.*?)\';/', file_get_contents( $version_php ), $matches )? $matches[1] : false;
397
+		if ( ! is_readable($version_php)) return false;
398
+		return preg_match('/\$wp_version\s*=\s*\'(.*?)\';/', file_get_contents($version_php), $matches) ? $matches[1] : false;
399 399
 	}
400 400
 
401 401
 
@@ -404,23 +404,23 @@  discard block
 block discarded – undo
404 404
 		if (preg_match('/\$wpmu_version\s*=\s*\'(.*?)\';/', file_get_contents($dir.'/wp-includes/version.php'), $matches)) {
405 405
 			$placeholders['version'] = $matches[1];
406 406
 		}
407
-		$output = is_null($output)? 'wordpress.pot' : $output;
407
+		$output = is_null($output) ? 'wordpress.pot' : $output;
408 408
 		return $this->xgettext('wp', $dir, $output, $placeholders);
409 409
 	}
410 410
 
411 411
 
412 412
 	function bb($dir, $output) {
413 413
 		$placeholders = array();
414
-		$output = is_null($output)? 'bbpress.pot' : $output;
414
+		$output = is_null($output) ? 'bbpress.pot' : $output;
415 415
 		return $this->xgettext('bb', $dir, $output, $placeholders);
416 416
 
417 417
 	}
418 418
 
419 419
 	function get_first_lines($filename, $lines = 30) {
420 420
 		$extf = fopen($filename, 'r');
421
-		if (!$extf) return false;
421
+		if ( ! $extf) return false;
422 422
 		$first_lines = '';
423
-		foreach(range(1, $lines) as $x) {
423
+		foreach (range(1, $lines) as $x) {
424 424
 			$line = fgets($extf);
425 425
 			if (feof($extf)) break;
426 426
 			if (false === $line) {
@@ -440,7 +440,7 @@  discard block
 block discarded – undo
440 440
 	}
441 441
 
442 442
 	function generic($dir, $output) {
443
-		$output = is_null($output)? "generic.pot" : $output;
443
+		$output = is_null($output) ? "generic.pot" : $output;
444 444
 		return $this->xgettext('generic', $dir, $output, array());
445 445
 	}
446 446
 
@@ -462,41 +462,41 @@  discard block
 block discarded – undo
462 462
 			$slug = $this->guess_plugin_slug($dir);
463 463
 		}
464 464
 
465
-		$plugins_dir = @opendir( $dir );
465
+		$plugins_dir = @opendir($dir);
466 466
 		$plugin_files = array();
467
-		if ( $plugins_dir ) {
468
-			while ( ( $file = readdir( $plugins_dir ) ) !== false ) {
469
-				if ( '.' === substr( $file, 0, 1 ) ) {
467
+		if ($plugins_dir) {
468
+			while (($file = readdir($plugins_dir)) !== false) {
469
+				if ('.' === substr($file, 0, 1)) {
470 470
 					continue;
471 471
 				}
472 472
 
473
-				if ( '.php' === substr( $file, -4 ) ) {
473
+				if ('.php' === substr($file, -4)) {
474 474
 					$plugin_files[] = $file;
475 475
 				}
476 476
 			}
477
-			closedir( $plugins_dir );
477
+			closedir($plugins_dir);
478 478
 		}
479 479
 
480
-		if ( empty( $plugin_files ) ) {
480
+		if (empty($plugin_files)) {
481 481
 			return false;
482 482
 		}
483 483
 
484 484
 		$main_file = '';
485
-		foreach ( $plugin_files as $plugin_file ) {
486
-			if ( ! is_readable( "$dir/$plugin_file" ) ) {
485
+		foreach ($plugin_files as $plugin_file) {
486
+			if ( ! is_readable("$dir/$plugin_file")) {
487 487
 				continue;
488 488
 			}
489 489
 
490
-			$source = $this->get_first_lines( "$dir/$plugin_file", $this->max_header_lines );
490
+			$source = $this->get_first_lines("$dir/$plugin_file", $this->max_header_lines);
491 491
 
492 492
 			// Stop when we find a file with a plugin name header in it.
493
-			if ( $this->get_addon_header( 'Plugin Name', $source ) != false ) {
493
+			if ($this->get_addon_header('Plugin Name', $source) != false) {
494 494
 				$main_file = "$dir/$plugin_file";
495 495
 				break;
496 496
 			}
497 497
 		}
498 498
 
499
-		if ( empty( $main_file ) ) {
499
+		if (empty($main_file)) {
500 500
 			return false;
501 501
 		}
502 502
 
@@ -505,9 +505,9 @@  discard block
 block discarded – undo
505 505
 		$placeholders['name'] = $this->get_addon_header('Plugin Name', $source);
506 506
 		$placeholders['slug'] = $slug;
507 507
 
508
-		$output = is_null($output)? "$slug.pot" : $output;
508
+		$output = is_null($output) ? "$slug.pot" : $output;
509 509
 		$res = $this->xgettext('wp-plugin', $dir, $output, $placeholders);
510
-		if (!$res) return false;
510
+		if ( ! $res) return false;
511 511
 		$potextmeta = new PotExtMeta;
512 512
 		$res = $potextmeta->append($main_file, $output);
513 513
 		/* Adding non-gettexted strings can repeat some phrases */
@@ -530,37 +530,37 @@  discard block
 block discarded – undo
530 530
 		$placeholders['name'] = $this->get_addon_header('Theme Name', $source);
531 531
 		$placeholders['slug'] = $slug;
532 532
 
533
-		$license = $this->get_addon_header( 'License', $source );
534
-		if ( $license )
533
+		$license = $this->get_addon_header('License', $source);
534
+		if ($license)
535 535
 			$this->meta['wp-theme']['comments'] = "Copyright (C) {year} {author}\nThis file is distributed under the {$license}.";
536 536
 		else
537 537
 			$this->meta['wp-theme']['comments'] = "Copyright (C) {year} {author}\nThis file is distributed under the same license as the {package-name} package.";
538 538
 
539
-		$output = is_null($output)? "$slug.pot" : $output;
539
+		$output = is_null($output) ? "$slug.pot" : $output;
540 540
 		$res = $this->xgettext('wp-theme', $dir, $output, $placeholders);
541
-		if (! $res )
541
+		if ( ! $res)
542 542
 			return false;
543 543
 		$potextmeta = new PotExtMeta;
544
-		$res = $potextmeta->append( $main_file, $output, array( 'Theme Name', 'Theme URI', 'Description', 'Author', 'Author URI' ) );
545
-		if ( ! $res )
544
+		$res = $potextmeta->append($main_file, $output, array('Theme Name', 'Theme URI', 'Description', 'Author', 'Author URI'));
545
+		if ( ! $res)
546 546
 			return false;
547 547
 		// If we're dealing with a pre-3.4 default theme, don't extract page templates before 3.4.
548
-		$extract_templates = ! in_array( $slug, array( 'twentyten', 'twentyeleven', 'default', 'classic' ) );
549
-		if ( ! $extract_templates ) {
550
-			$wp_dir = dirname( dirname( dirname( $dir ) ) );
551
-			$extract_templates = file_exists( "$wp_dir/wp-admin/user/about.php" ) || ! file_exists( "$wp_dir/wp-load.php" );
548
+		$extract_templates = ! in_array($slug, array('twentyten', 'twentyeleven', 'default', 'classic'));
549
+		if ( ! $extract_templates) {
550
+			$wp_dir = dirname(dirname(dirname($dir)));
551
+			$extract_templates = file_exists("$wp_dir/wp-admin/user/about.php") || ! file_exists("$wp_dir/wp-load.php");
552 552
 		}
553
-		if ( $extract_templates ) {
554
-			$res = $potextmeta->append( $dir, $output, array( 'Template Name' ) );
555
-			if ( ! $res )
553
+		if ($extract_templates) {
554
+			$res = $potextmeta->append($dir, $output, array('Template Name'));
555
+			if ( ! $res)
556 556
 				return false;
557
-			$files = scandir( $dir );
558
-			foreach ( $files as $file ) {
559
-				if ( '.' == $file[0] || 'CVS' == $file )
557
+			$files = scandir($dir);
558
+			foreach ($files as $file) {
559
+				if ('.' == $file[0] || 'CVS' == $file)
560 560
 					continue;
561
-				if ( is_dir( $dir . '/' . $file ) ) {
562
-					$res = $potextmeta->append( $dir . '/' . $file, $output, array( 'Template Name' ) );
563
-					if ( ! $res )
561
+				if (is_dir($dir.'/'.$file)) {
562
+					$res = $potextmeta->append($dir.'/'.$file, $output, array('Template Name'));
563
+					if ( ! $res)
564 564
 						return false;
565 565
 				}
566 566
 			}
@@ -572,47 +572,47 @@  discard block
 block discarded – undo
572 572
 	}
573 573
 
574 574
 	function bp($dir, $output) {
575
-		$output = is_null($output)? "buddypress.pot" : $output;
575
+		$output = is_null($output) ? "buddypress.pot" : $output;
576 576
 		return $this->xgettext('bp', $dir, $output, array(), array('bp-forums/bbpress/.*'));
577 577
 	}
578 578
 
579
-	function glotpress( $dir, $output ) {
580
-		$output = is_null( $output ) ? "glotpress.pot" : $output;
581
-		return $this->xgettext( 'glotpress', $dir, $output );
579
+	function glotpress($dir, $output) {
580
+		$output = is_null($output) ? "glotpress.pot" : $output;
581
+		return $this->xgettext('glotpress', $dir, $output);
582 582
 	}
583 583
 
584
-	function wporg_bb_forums( $dir, $output ) {
585
-		$output = is_null( $output ) ? 'wporg.pot' : $output;
586
-		return $this->xgettext( 'wporg-bb-forums', $dir, $output, array(), array(
584
+	function wporg_bb_forums($dir, $output) {
585
+		$output = is_null($output) ? 'wporg.pot' : $output;
586
+		return $this->xgettext('wporg-bb-forums', $dir, $output, array(), array(
587 587
 			'bb-plugins/elfakismet/.*',
588 588
 			'bb-plugins/support-forum/.*',
589
-		) );
589
+		));
590 590
 	}
591 591
 
592
-	function rosetta( $dir, $output ) {
593
-		$output = is_null( $output )? 'rosetta.pot' : $output;
594
-		return $this->xgettext( 'rosetta', $dir, $output, array(), array(), array(
592
+	function rosetta($dir, $output) {
593
+		$output = is_null($output) ? 'rosetta.pot' : $output;
594
+		return $this->xgettext('rosetta', $dir, $output, array(), array(), array(
595 595
 			'mu-plugins/(roles|showcase|downloads)/.*\.php',
596 596
 			'mu-plugins/rosetta.*\.php',
597 597
 			'mu-plugins/rosetta/[^/]+\.php',
598 598
 			'mu-plugins/rosetta/tmpl/.*\.php',
599 599
 			'themes/rosetta/.*\.php',
600
-		) );
600
+		));
601 601
 	}
602 602
 
603
-	function is_ms_file( $file_name ) {
603
+	function is_ms_file($file_name) {
604 604
 		$is_ms_file = false;
605
-		$prefix = substr( $file_name, 0, 2 ) === './'? '\./' : '';
606
-		foreach( $this->ms_files as $ms_file )
607
-			if ( preg_match( '|^'.$prefix.$ms_file.'$|', $file_name ) ) {
605
+		$prefix = substr($file_name, 0, 2) === './' ? '\./' : '';
606
+		foreach ($this->ms_files as $ms_file)
607
+			if (preg_match('|^'.$prefix.$ms_file.'$|', $file_name)) {
608 608
 				$is_ms_file = true;
609 609
 				break;
610 610
 			}
611 611
 		return $is_ms_file;
612 612
 	}
613 613
 
614
-	function is_not_ms_file( $file_name ) {
615
-		return !$this->is_ms_file( $file_name );
614
+	function is_not_ms_file($file_name) {
615
+		return ! $this->is_ms_file($file_name);
616 616
 	}
617 617
 }
618 618
 
@@ -622,7 +622,7 @@  discard block
 block discarded – undo
622 622
 if ($included_files[0] == __FILE__) {
623 623
 	$makepot = new MakePOT;
624 624
 	if ((3 == count($argv) || 4 == count($argv)) && in_array($method = str_replace('-', '_', $argv[1]), get_class_methods($makepot))) {
625
-		$res = call_user_func(array($makepot, $method), realpath($argv[2]), isset($argv[3])? $argv[3] : null);
625
+		$res = call_user_func(array($makepot, $method), realpath($argv[2]), isset($argv[3]) ? $argv[3] : null);
626 626
 		if (false === $res) {
627 627
 			fwrite(STDERR, "Couldn't generate POT file!\n");
628 628
 		}
Please login to merge, or discard this patch.
tools/i18n/extract.php 1 patch
Spacing   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-$pomo = dirname( dirname( dirname( __FILE__ ) ) ) . '/src/wp-includes/pomo';
2
+$pomo = dirname(dirname(dirname(__FILE__))).'/src/wp-includes/pomo';
3 3
 require_once "$pomo/entry.php";
4 4
 require_once "$pomo/translations.php";
5 5
 
@@ -10,55 +10,55 @@  discard block
 block discarded – undo
10 10
 class StringExtractor {
11 11
 
12 12
 	var $rules = array(
13
-		'__' => array( 'string' ),
14
-		'_e' => array( 'string' ),
15
-		'_n' => array( 'singular', 'plural' ),
13
+		'__' => array('string'),
14
+		'_e' => array('string'),
15
+		'_n' => array('singular', 'plural'),
16 16
 	);
17 17
 	var $comment_prefix = 'translators:';
18 18
 
19
-	function __construct( $rules = array() ) {
19
+	function __construct($rules = array()) {
20 20
 		$this->rules = $rules;
21 21
 	}
22 22
 
23
-	function extract_from_directory( $dir, $excludes = array(), $includes = array(), $prefix = '' ) {
23
+	function extract_from_directory($dir, $excludes = array(), $includes = array(), $prefix = '') {
24 24
 		$old_cwd = getcwd();
25
-		chdir( $dir );
25
+		chdir($dir);
26 26
 		$translations = new Translations;
27
-		$file_names = (array) scandir( '.' );
28
-		foreach ( $file_names as $file_name ) {
29
-			if ( '.' == $file_name || '..' == $file_name ) continue;
30
-			if ( preg_match( '/\.php$/', $file_name ) && $this->does_file_name_match( $prefix . $file_name, $excludes, $includes ) ) {
31
-				$extracted = $this->extract_from_file( $file_name, $prefix );
32
-				$translations->merge_originals_with( $extracted );
27
+		$file_names = (array) scandir('.');
28
+		foreach ($file_names as $file_name) {
29
+			if ('.' == $file_name || '..' == $file_name) continue;
30
+			if (preg_match('/\.php$/', $file_name) && $this->does_file_name_match($prefix.$file_name, $excludes, $includes)) {
31
+				$extracted = $this->extract_from_file($file_name, $prefix);
32
+				$translations->merge_originals_with($extracted);
33 33
 			}
34
-			if ( is_dir( $file_name ) ) {
35
-				$extracted = $this->extract_from_directory( $file_name, $excludes, $includes, $prefix . $file_name . '/' );
36
-				$translations->merge_originals_with( $extracted );
34
+			if (is_dir($file_name)) {
35
+				$extracted = $this->extract_from_directory($file_name, $excludes, $includes, $prefix.$file_name.'/');
36
+				$translations->merge_originals_with($extracted);
37 37
 			}
38 38
 		}
39
-		chdir( $old_cwd );
39
+		chdir($old_cwd);
40 40
 		return $translations;
41 41
 	}
42 42
 
43
-	function extract_from_file( $file_name, $prefix ) {
44
-		$code = file_get_contents( $file_name );
45
-		return $this->extract_from_code( $code, $prefix . $file_name );
43
+	function extract_from_file($file_name, $prefix) {
44
+		$code = file_get_contents($file_name);
45
+		return $this->extract_from_code($code, $prefix.$file_name);
46 46
 	}
47 47
 
48
-	function does_file_name_match( $path, $excludes, $includes ) {
49
-		if ( $includes ) {
48
+	function does_file_name_match($path, $excludes, $includes) {
49
+		if ($includes) {
50 50
 			$matched_any_include = false;
51
-			foreach( $includes as $include ) {
52
-				if ( preg_match( '|^'.$include.'$|', $path ) ) {
51
+			foreach ($includes as $include) {
52
+				if (preg_match('|^'.$include.'$|', $path)) {
53 53
 					$matched_any_include = true;
54 54
 					break;
55 55
 				}
56 56
 			}
57
-			if ( !$matched_any_include ) return false;
57
+			if ( ! $matched_any_include) return false;
58 58
 		}
59
-		if ( $excludes ) {
60
-			foreach( $excludes as $exclude ) {
61
-				if ( preg_match( '|^'.$exclude.'$|', $path ) ) {
59
+		if ($excludes) {
60
+			foreach ($excludes as $exclude) {
61
+				if (preg_match('|^'.$exclude.'$|', $path)) {
62 62
 					return false;
63 63
 				}
64 64
 			}
@@ -66,17 +66,17 @@  discard block
 block discarded – undo
66 66
 		return true;
67 67
 	}
68 68
 
69
-	function entry_from_call( $call, $file_name ) {
70
-		$rule = isset( $this->rules[$call['name']] )? $this->rules[$call['name']] : null;
71
-		if ( !$rule ) return null;
69
+	function entry_from_call($call, $file_name) {
70
+		$rule = isset($this->rules[$call['name']]) ? $this->rules[$call['name']] : null;
71
+		if ( ! $rule) return null;
72 72
 		$entry = new Translation_Entry;
73 73
 		$multiple = array();
74 74
 		$complete = false;
75
-		for( $i = 0; $i < count( $rule ); ++$i ) {
76
-			if ( $rule[$i] && ( !isset( $call['args'][$i] ) || !is_string( $call['args'][$i] ) || '' == $call['args'][$i] ) ) return false;
77
-			switch( $rule[$i] ) {
75
+		for ($i = 0; $i < count($rule); ++$i) {
76
+			if ($rule[$i] && ( ! isset($call['args'][$i]) || ! is_string($call['args'][$i]) || '' == $call['args'][$i])) return false;
77
+			switch ($rule[$i]) {
78 78
 			case 'string':
79
-				if ( $complete ) {
79
+				if ($complete) {
80 80
 					$multiple[] = $entry;
81 81
 					$entry = new Translation_Entry;
82 82
 					$complete = false;
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 				$complete = true;
86 86
 				break;
87 87
 			case 'singular':
88
-				if ( $complete ) {
88
+				if ($complete) {
89 89
 					$multiple[] = $entry;
90 90
 					$entry = new Translation_Entry;
91 91
 					$complete = false;
@@ -100,27 +100,27 @@  discard block
 block discarded – undo
100 100
 				break;
101 101
 			case 'context':
102 102
 				$entry->context = $call['args'][$i];
103
-				foreach( $multiple as &$single_entry ) {
103
+				foreach ($multiple as &$single_entry) {
104 104
 					$single_entry->context = $entry->context;
105 105
 				}
106 106
 				break;
107 107
 			}
108 108
 		}
109
-		if ( isset( $call['line'] ) && $call['line'] ) {
110
-			$references = array( $file_name . ':' . $call['line'] );
109
+		if (isset($call['line']) && $call['line']) {
110
+			$references = array($file_name.':'.$call['line']);
111 111
 			$entry->references = $references;
112
-			foreach( $multiple as &$single_entry ) {
112
+			foreach ($multiple as &$single_entry) {
113 113
 				$single_entry->references = $references;
114 114
 			}
115 115
 		}
116
-		if ( isset( $call['comment'] ) && $call['comment'] ) {
117
-			$comments = rtrim( $call['comment'] ) . "\n";
116
+		if (isset($call['comment']) && $call['comment']) {
117
+			$comments = rtrim($call['comment'])."\n";
118 118
 			$entry->extracted_comments = $comments;
119
-			foreach( $multiple as &$single_entry ) {
119
+			foreach ($multiple as &$single_entry) {
120 120
 				$single_entry->extracted_comments = $comments;
121 121
 			}
122 122
 		}
123
-		if ( $multiple && $entry ) {
123
+		if ($multiple && $entry) {
124 124
 			$multiple[] = $entry;
125 125
 			return $multiple;
126 126
 		}
@@ -128,16 +128,16 @@  discard block
 block discarded – undo
128 128
 		return $entry;
129 129
 	}
130 130
 
131
-	function extract_from_code( $code, $file_name ) {
131
+	function extract_from_code($code, $file_name) {
132 132
 		$translations = new Translations;
133
-		$function_calls = $this->find_function_calls( array_keys( $this->rules ), $code );
134
-		foreach( $function_calls as $call ) {
135
-			$entry = $this->entry_from_call( $call, $file_name );
136
-			if ( is_array( $entry ) )
137
-				foreach( $entry as $single_entry )
138
-					$translations->add_entry_or_merge( $single_entry );
139
-			elseif ( $entry)
140
-				$translations->add_entry_or_merge( $entry );
133
+		$function_calls = $this->find_function_calls(array_keys($this->rules), $code);
134
+		foreach ($function_calls as $call) {
135
+			$entry = $this->entry_from_call($call, $file_name);
136
+			if (is_array($entry))
137
+				foreach ($entry as $single_entry)
138
+					$translations->add_entry_or_merge($single_entry);
139
+			elseif ($entry)
140
+				$translations->add_entry_or_merge($entry);
141 141
 		}
142 142
 		return $translations;
143 143
 	}
@@ -148,70 +148,70 @@  discard block
 block discarded – undo
148 148
 	 *	- args - array for the function arguments. Each string literal is represented by itself, other arguments are represented by null.
149 149
 	 *  - line - line number
150 150
 	 */
151
-	function find_function_calls( $function_names, $code ) {
152
-		$tokens = token_get_all( $code );
151
+	function find_function_calls($function_names, $code) {
152
+		$tokens = token_get_all($code);
153 153
 		$function_calls = array();
154 154
 		$latest_comment = false;
155 155
 		$in_func = false;
156
-		foreach( $tokens as $token ) {
156
+		foreach ($tokens as $token) {
157 157
 			$id = $text = null;
158
-			if ( is_array( $token ) ) list( $id, $text, $line ) = $token;
159
-			if ( T_WHITESPACE == $id ) continue;
160
-			if ( T_STRING == $id && in_array( $text, $function_names ) && !$in_func ) {
158
+			if (is_array($token)) list($id, $text, $line) = $token;
159
+			if (T_WHITESPACE == $id) continue;
160
+			if (T_STRING == $id && in_array($text, $function_names) && ! $in_func) {
161 161
 				$in_func = true;
162 162
 				$paren_level = -1;
163 163
 				$args = array();
164 164
 				$func_name = $text;
165 165
 				$func_line = $line;
166
-				$func_comment = $latest_comment? $latest_comment : '';
166
+				$func_comment = $latest_comment ? $latest_comment : '';
167 167
 
168 168
 				$just_got_into_func = true;
169 169
 				$latest_comment = false;
170 170
 				continue;
171 171
 			}
172
-			if ( T_COMMENT == $id ) {
173
-				$text = preg_replace( '%^\s+\*\s%m', '', $text );
174
-				$text = str_replace( array( "\r\n", "\n" ), ' ', $text );;
175
-				$text = trim( preg_replace( '%^/\*|//%', '', preg_replace( '%\*/$%', '', $text ) ) );
176
-				if ( 0 === stripos( $text, $this->comment_prefix ) ) {
172
+			if (T_COMMENT == $id) {
173
+				$text = preg_replace('%^\s+\*\s%m', '', $text);
174
+				$text = str_replace(array("\r\n", "\n"), ' ', $text); ;
175
+				$text = trim(preg_replace('%^/\*|//%', '', preg_replace('%\*/$%', '', $text)));
176
+				if (0 === stripos($text, $this->comment_prefix)) {
177 177
 					$latest_comment = $text;
178 178
 				}
179 179
 			}
180
-			if ( !$in_func ) continue;
181
-			if ( '(' == $token ) {
180
+			if ( ! $in_func) continue;
181
+			if ('(' == $token) {
182 182
 				$paren_level++;
183
-				if ( 0 == $paren_level ) { // start of first argument
183
+				if (0 == $paren_level) { // start of first argument
184 184
 					$just_got_into_func = false;
185 185
 					$current_argument = null;
186 186
 					$current_argument_is_just_literal = true;
187 187
 				}
188 188
 				continue;
189 189
 			}
190
-			if ( $just_got_into_func ) {
190
+			if ($just_got_into_func) {
191 191
 				// there wasn't a opening paren just after the function name -- this means it is not a function
192 192
 				$in_func = false;
193 193
 				$just_got_into_func = false;
194 194
 			}
195
-			if ( ')' == $token ) {
196
-				if ( 0 == $paren_level ) {
195
+			if (')' == $token) {
196
+				if (0 == $paren_level) {
197 197
 					$in_func = false;
198 198
 					$args[] = $current_argument;
199
-					$call = array( 'name' => $func_name, 'args' => $args, 'line' => $func_line );
200
-					if ( $func_comment ) $call['comment'] = $func_comment;
199
+					$call = array('name' => $func_name, 'args' => $args, 'line' => $func_line);
200
+					if ($func_comment) $call['comment'] = $func_comment;
201 201
 					$function_calls[] = $call;
202 202
 				}
203 203
 				$paren_level--;
204 204
 				continue;
205 205
 			}
206
-			if ( ',' == $token && 0 == $paren_level ) {
206
+			if (',' == $token && 0 == $paren_level) {
207 207
 				$args[] = $current_argument;
208 208
 				$current_argument = null;
209 209
 				$current_argument_is_just_literal = true;
210 210
 				continue;
211 211
 			}
212
-			if ( T_CONSTANT_ENCAPSED_STRING == $id && $current_argument_is_just_literal ) {
212
+			if (T_CONSTANT_ENCAPSED_STRING == $id && $current_argument_is_just_literal) {
213 213
 				// we can use eval safely, because we are sure $text is just a string literal
214
-				eval('$current_argument = '.$text.';' );
214
+				eval('$current_argument = '.$text.';');
215 215
 				continue;
216 216
 			}
217 217
 			$current_argument_is_just_literal = false;
Please login to merge, or discard this patch.