Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Introduce wp_load_translations_early(), which can be used before the …

…locale is properly loaded in order to translate early error strings. Internationalize setup-config.php -- translators no longer have a reason to modify this file. fixes #18180.

git-svn-id: http://svn.automattic.com/wordpress/trunk@19760 1a063a9b-81f0-0310-95a4-ce76da25c4cd
  • Loading branch information...
commit 81ed9a7563e5ad4c0edccd059bc4ea7d9c1a4a10 1 parent e106811
authored January 26, 2012
95  wp-admin/setup-config.php
@@ -41,31 +41,31 @@
41 41
 define('WP_DEBUG', false);
42 42
 /**#@-*/
43 43
 
44  
-require_once(ABSPATH . WPINC . '/load.php');
45  
-require_once(ABSPATH . WPINC . '/version.php');
  44
+require(ABSPATH . WPINC . '/load.php');
  45
+require(ABSPATH . WPINC . '/version.php');
  46
+
  47
+// Also loads functions.php, plugin.php, l10n.php, pomo/mo.php (all required by setup-config.php)
  48
+wp_load_translations_early();
  49
+
46 50
 wp_check_php_mysql_versions();
47 51
 
48 52
 require_once(ABSPATH . WPINC . '/compat.php');
49  
-require_once(ABSPATH . WPINC . '/functions.php');
50 53
 require_once(ABSPATH . WPINC . '/class-wp-error.php');
51 54
 
52  
-if (!file_exists(ABSPATH . 'wp-config-sample.php'))
53  
-	wp_die('Sorry, I need a wp-config-sample.php file to work from. Please re-upload this file from your WordPress installation.');
  55
+if ( ! file_exists( ABSPATH . 'wp-config-sample.php' ) )
  56
+	wp_die( __( 'Sorry, I need a wp-config-sample.php file to work from. Please re-upload this file from your WordPress installation.' ) );
54 57
 
55 58
 $config_file = file(ABSPATH . 'wp-config-sample.php');
56 59
 
57 60
 // Check if wp-config.php has been created
58  
-if (file_exists(ABSPATH . 'wp-config.php'))
59  
-	wp_die("<p>The file 'wp-config.php' already exists. If you need to reset any of the configuration items in this file, please delete it first. You may try <a href='install.php'>installing now</a>.</p>");
  61
+if ( file_exists( ABSPATH . 'wp-config.php' ) )
  62
+	wp_die( '<p>' . sprintf( __( "The file 'wp-config.php' already exists. If you need to reset any of the configuration items in this file, please delete it first. You may try <a href='%s'>installing now</a>." ), 'install.php' ) . '</p>' );
60 63
 
61 64
 // Check if wp-config.php exists above the root directory but is not part of another install
62  
-if (file_exists(ABSPATH . '../wp-config.php') && ! file_exists(ABSPATH . '../wp-settings.php'))
63  
-	wp_die("<p>The file 'wp-config.php' already exists one level above your WordPress installation. If you need to reset any of the configuration items in this file, please delete it first. You may try <a href='install.php'>installing now</a>.</p>");
  65
+if ( file_exists(ABSPATH . '../wp-config.php' ) && ! file_exists( ABSPATH . '../wp-settings.php' ) )
  66
+	wp_die( '<p>' . sprintf( __( "The file 'wp-config.php' already exists one level above your WordPress installation. If you need to reset any of the configuration items in this file, please delete it first. You may try <a href='install.php'>installing now</a>."), 'install.php' ) . '</p>' );
64 67
 
65  
-if (isset($_GET['step']))
66  
-	$step = $_GET['step'];
67  
-else
68  
-	$step = 0;
  68
+$step = isset( $_GET['step'] ) ? (int) $_GET['step'] : 0;
69 69
 
70 70
 /**
71 71
  * Display setup wp-config.php file header.
@@ -82,7 +82,7 @@ function display_header() {
82 82
 <html xmlns="http://www.w3.org/1999/xhtml">
83 83
 <head>
84 84
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
85  
-<title>WordPress &rsaquo; Setup Configuration File</title>
  85
+<title><?php _e( 'WordPress &rsaquo; Setup Configuration File' ); ?></title>
86 86
 <link rel="stylesheet" href="css/install.css" type="text/css" />
87 87
 
88 88
 </head>
@@ -96,18 +96,18 @@ function display_header() {
96 96
 		display_header();
97 97
 ?>
98 98
 
99  
-<p>Welcome to WordPress. Before getting started, we need some information on the database. You will need to know the following items before proceeding.</p>
  99
+<p><?php _e( 'Welcome to WordPress. Before getting started, we need some information on the database. You will need to know the following items before proceeding.' ) ?></p>
100 100
 <ol>
101  
-	<li>Database name</li>
102  
-	<li>Database username</li>
103  
-	<li>Database password</li>
104  
-	<li>Database host</li>
105  
-	<li>Table prefix (if you want to run more than one WordPress in a single database) </li>
  101
+	<li><?php _e( 'Database name' ); ?></li>
  102
+	<li><?php _e( 'Database username' ); ?></li>
  103
+	<li><?php _e( 'Database password' ); ?></li>
  104
+	<li><?php _e( 'Database host' ); ?></li>
  105
+	<li><?php _e( 'Table prefix (if you want to run more than one WordPress in a single database)' ); ?></li>
106 106
 </ol>
107  
-<p><strong>If for any reason this automatic file creation doesn't work, don't worry. All this does is fill in the database information to a configuration file. You may also simply open <code>wp-config-sample.php</code> in a text editor, fill in your information, and save it as <code>wp-config.php</code>. </strong></p>
108  
-<p>In all likelihood, these items were supplied to you by your Web Host. If you do not have this information, then you will need to contact them before you can continue. If you&#8217;re all ready&hellip;</p>
  107
+<p><strong><?php _e( "If for any reason this automatic file creation doesn't work, don't worry. All this does is fill in the database information to a configuration file. You may also simply open <code>wp-config-sample.php</code> in a text editor, fill in your information, and save it as <code>wp-config.php</code>. </strong></p>
  108
+<p>In all likelihood, these items were supplied to you by your Web Host. If you do not have this information, then you will need to contact them before you can continue. If you&#8217;re all ready&hellip;" ); ?></p>
109 109
 
110  
-<p class="step"><a href="setup-config.php?step=1<?php if ( isset( $_GET['noapi'] ) ) echo '&amp;noapi'; ?>" class="button">Let&#8217;s go!</a></p>
  110
+<p class="step"><a href="setup-config.php?step=1<?php if ( isset( $_GET['noapi'] ) ) echo '&amp;noapi'; ?>" class="button"><?php _e( 'Let&#8217;s go!' ); ?></a></p>
111 111
 <?php
112 112
 	break;
113 113
 
@@ -115,36 +115,36 @@ function display_header() {
115 115
 		display_header();
116 116
 	?>
117 117
 <form method="post" action="setup-config.php?step=2">
118  
-	<p>Below you should enter your database connection details. If you're not sure about these, contact your host. </p>
  118
+	<p><?php _e( "Below you should enter your database connection details. If you're not sure about these, contact your host." ); ?></p>
119 119
 	<table class="form-table">
120 120
 		<tr>
121  
-			<th scope="row"><label for="dbname">Database Name</label></th>
  121
+			<th scope="row"><label for="dbname"><?php _e( 'Database Name' ); ?></label></th>
122 122
 			<td><input name="dbname" id="dbname" type="text" size="25" value="wordpress" /></td>
123  
-			<td>The name of the database you want to run WP in. </td>
  123
+			<td><?php _e( 'The name of the database you want to run WP in.' ); ?></td>
124 124
 		</tr>
125 125
 		<tr>
126  
-			<th scope="row"><label for="uname">User Name</label></th>
127  
-			<td><input name="uname" id="uname" type="text" size="25" value="username" /></td>
128  
-			<td>Your MySQL username</td>
  126
+			<th scope="row"><label for="uname"><?php _e( 'User Name' ); ?></label></th>
  127
+			<td><input name="uname" id="uname" type="text" size="25" value="<?php echo htmlspecialchars( _x( 'username', 'example username' ), ENT_QUOTES ); ?>" /></td>
  128
+			<td><?php _e( 'Your MySQL username' ); ?></td>
129 129
 		</tr>
130 130
 		<tr>
131  
-			<th scope="row"><label for="pwd">Password</label></th>
132  
-			<td><input name="pwd" id="pwd" type="text" size="25" value="password" /></td>
133  
-			<td>...and your MySQL password.</td>
  131
+			<th scope="row"><label for="pwd"><?php _e( 'Password' ); ?></label></th>
  132
+			<td><input name="pwd" id="pwd" type="text" size="25" value="<?php echo htmlspecialchars( _x( 'password', 'example password' ), ENT_QUOTES ); ?>" /></td>
  133
+			<td><?php _e( '&hellip;and your MySQL password.' ); ?></td>
134 134
 		</tr>
135 135
 		<tr>
136  
-			<th scope="row"><label for="dbhost">Database Host</label></th>
  136
+			<th scope="row"><label for="dbhost"><?php _e( 'Database Host' ); ?></label></th>
137 137
 			<td><input name="dbhost" id="dbhost" type="text" size="25" value="localhost" /></td>
138  
-			<td>You should be able to get this info from your web host, if <code>localhost</code> does not work.</td>
  138
+			<td><?php _e( 'You should be able to get this info from your web host, if <code>localhost</code> does not work.' ); ?></td>
139 139
 		</tr>
140 140
 		<tr>
141  
-			<th scope="row"><label for="prefix">Table Prefix</label></th>
  141
+			<th scope="row"><label for="prefix"><?php _e( 'Table Prefix' ); ?></label></th>
142 142
 			<td><input name="prefix" id="prefix" type="text" value="wp_" size="25" /></td>
143  
-			<td>If you want to run multiple WordPress installations in a single database, change this.</td>
  143
+			<td><?php _e( 'If you want to run multiple WordPress installations in a single database, change this.' ); ?></td>
144 144
 		</tr>
145 145
 	</table>
146  
-	<?php if ( isset( $_GET['noapi'] ) ) { ?><input name="noapi" type="hidden" value="true" /><?php } ?>
147  
-	<p class="step"><input name="submit" type="submit" value="Submit" class="button" /></p>
  146
+	<?php if ( isset( $_GET['noapi'] ) ) { ?><input name="noapi" type="hidden" value="1" /><?php } ?>
  147
+	<p class="step"><input name="submit" type="submit" value="<?php echo htmlspecialchars( __( 'Submit' ), ENT_QUOTES ); ?>" class="button" /></p>
148 148
 </form>
149 149
 <?php
150 150
 	break;
@@ -160,7 +160,7 @@ function display_header() {
160 160
 
161 161
 	// Validate $prefix: it can only contain letters, numbers and underscores
162 162
 	if ( preg_match( '|[^a-z0-9_]|i', $prefix ) )
163  
-		wp_die( /*WP_I18N_BAD_PREFIX*/'<strong>ERROR</strong>: "Table Prefix" can only contain numbers, letters, and underscores.'/*/WP_I18N_BAD_PREFIX*/ );
  163
+		wp_die( __( '<strong>ERROR</strong>: "Table Prefix" can only contain numbers, letters, and underscores.' ) );
164 164
 
165 165
 	// Test the db connection.
166 166
 	/**#@+
@@ -175,15 +175,12 @@ function display_header() {
175 175
 	// We'll fail here if the values are no good.
176 176
 	require_wp_db();
177 177
 	if ( ! empty( $wpdb->error ) ) {
178  
-		$back = '<p class="step"><a href="setup-config.php?step=1" onclick="javascript:history.go(-1);return false;" class="button">Try Again</a></p>';
  178
+		$back = '<p class="step"><a href="setup-config.php?step=1" onclick="javascript:history.go(-1);return false;" class="button">' . __( 'Try Again' ) . '</a></p>';
179 179
 		wp_die( $wpdb->error->get_error_message() . $back );
180 180
 	}
181 181
 
182 182
 	// Fetch or generate keys and salts.
183 183
 	$no_api = isset( $_POST['noapi'] );
184  
-	require_once( ABSPATH . WPINC . '/plugin.php' );
185  
-	require_once( ABSPATH . WPINC . '/l10n.php' );
186  
-	require_once( ABSPATH . WPINC . '/pomo/translations.php' );
187 184
 	if ( ! $no_api ) {
188 185
 		require_once( ABSPATH . WPINC . '/class-http.php' );
189 186
 		require_once( ABSPATH . WPINC . '/http.php' );
@@ -248,15 +245,15 @@ function get_bloginfo() {
248 245
 	if ( ! is_writable(ABSPATH) ) :
249 246
 		display_header();
250 247
 ?>
251  
-<p>Sorry, but I can't write the <code>wp-config.php</code> file.</p>
252  
-<p>You can create the <code>wp-config.php</code> manually and paste the following text into it.</p>
  248
+<p><?php _e( "Sorry, but I can't write the <code>wp-config.php</code> file." ); ?></p>
  249
+<p><?php _e( 'You can create the <code>wp-config.php</code> manually and paste the following text into it.' ); ?></p>
253 250
 <textarea cols="98" rows="15" class="code"><?php
254 251
 		foreach( $config_file as $line ) {
255 252
 			echo htmlentities($line, ENT_COMPAT, 'UTF-8');
256 253
 		}
257 254
 ?></textarea>
258  
-<p>After you've done that, click "Run the install."</p>
259  
-<p class="step"><a href="install.php" class="button">Run the install</a></p>
  255
+<p><?php _e( 'After you\'ve done that, click "Run the install."' ); ?></p>
  256
+<p class="step"><a href="install.php" class="button"><?php _e( 'Run the install' ); ?></a></p>
260 257
 <?php
261 258
 	else :
262 259
 		$handle = fopen(ABSPATH . 'wp-config.php', 'w');
@@ -267,9 +264,9 @@ function get_bloginfo() {
267 264
 		chmod(ABSPATH . 'wp-config.php', 0666);
268 265
 		display_header();
269 266
 ?>
270  
-<p>All right sparky! You've made it through this part of the installation. WordPress can now communicate with your database. If you are ready, time now to&hellip;</p>
  267
+<p><?php _e( "All right sparky! You've made it through this part of the installation. WordPress can now communicate with your database. If you are ready, time now to&hellip;" ); ?></p>
271 268
 
272  
-<p class="step"><a href="install.php" class="button">Run the install</a></p>
  269
+<p class="step"><a href="install.php" class="button"><?php _e( 'Run the install' ); ?></a></p>
273 270
 <?php
274 271
 	endif;
275 272
 	break;
10  wp-includes/functions.php
@@ -1201,8 +1201,10 @@ function is_blog_installed() {
1201 1201
 
1202 1202
 		// One or more tables exist. We are insane.
1203 1203
 
  1204
+		wp_load_translations_early();
  1205
+
1204 1206
 		// Die with a DB error.
1205  
-		$wpdb->error = sprintf( /*WP_I18N_NO_TABLES*/'One or more database tables are unavailable. The database may need to be <a href="%s">repaired</a>.'/*/WP_I18N_NO_TABLES*/, 'maint/repair.php?referrer=is_blog_installed' );
  1207
+		$wpdb->error = sprintf( __( 'One or more database tables are unavailable. The database may need to be <a href="%s">repaired</a>.' ), 'maint/repair.php?referrer=is_blog_installed' );
1206 1208
 		dead_db();
1207 1209
 	}
1208 1210
 
@@ -2647,16 +2649,18 @@ function dead_db() {
2647 2649
 	status_header( 500 );
2648 2650
 	nocache_headers();
2649 2651
 	header( 'Content-Type: text/html; charset=utf-8' );
  2652
+
  2653
+	wp_load_translations_early();
2650 2654
 ?>
2651 2655
 <!DOCTYPE html>
2652 2656
 <html xmlns="http://www.w3.org/1999/xhtml" <?php if ( function_exists( 'language_attributes' ) ) language_attributes(); ?>>
2653 2657
 <head>
2654 2658
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
2655  
-	<title><?php echo /*WP_I18N_DB_ERROR*/'Database Error'/*/WP_I18N_DB_ERROR*/; ?></title>
  2659
+	<title><?php _e( 'Database Error' ); ?></title>
2656 2660
 
2657 2661
 </head>
2658 2662
 <body>
2659  
-	<h1><?php echo /*WP_I18N_DB_CONNECTION_ERROR*/'Error establishing a database connection'/*/WP_I18N_DB_CONNECTION_ERROR*/; ?></h1>
  2663
+	<h1><?php _e( 'Error establishing a database connection' ); ?></h1>
2660 2664
 </body>
2661 2665
 </html>
2662 2666
 <?php
115  wp-includes/load.php
@@ -19,7 +19,7 @@ function wp_unregister_GLOBALS() {
19 19
 		return;
20 20
 
21 21
 	if ( isset( $_REQUEST['GLOBALS'] ) )
22  
-		die( /*WP_I18N_GLOBALS_OVERWRITE*/'GLOBALS overwrite attempt detected'/*/WP_I18N_GLOBALS_OVERWRITE*/ );
  22
+		die( 'GLOBALS overwrite attempt detected' );
23 23
 
24 24
 	// Variables that shouldn't be unset
25 25
 	$no_unset = array( 'GLOBALS', '_GET', '_POST', '_COOKIE', '_REQUEST', '_SERVER', '_ENV', '_FILES', 'table_prefix' );
@@ -97,22 +97,21 @@ function wp_fix_server_vars() {
97 97
  *
98 98
  * Dies if requirements are not met.
99 99
  *
100  
- * This function must be able to work without a complete environment set up. In wp-load.php, for
101  
- * example, WP_CONTENT_DIR is defined and version.php is included before this function is called.
102  
- *
103 100
  * @access private
104 101
  * @since 3.0.0
105 102
  */
106 103
 function wp_check_php_mysql_versions() {
107  
-	// we can probably extend this function to check if wp_die() exists then use translated strings, and then use it in install.php etc.
108  
-
109 104
 	global $required_php_version, $wp_version;
110 105
 	$php_version = phpversion();
111  
-	if ( version_compare( $required_php_version, $php_version, '>' ) )
112  
-		die( sprintf( /*WP_I18N_OLD_PHP*/'Your server is running PHP version %1$s but WordPress %2$s requires at least %3$s.'/*/WP_I18N_OLD_PHP*/, $php_version, $wp_version, $required_php_version ) );
  106
+	if ( version_compare( $required_php_version, $php_version, '>' ) ) {
  107
+		wp_load_translations_early();
  108
+		wp_die( sprintf( __( 'Your server is running PHP version %1$s but WordPress %2$s requires at least %3$s.' ), $php_version, $wp_version, $required_php_version ) );
  109
+	}
113 110
 
114  
-	if ( !extension_loaded( 'mysql' ) && !file_exists( WP_CONTENT_DIR . '/db.php' ) )
115  
-		die( /*WP_I18N_OLD_MYSQL*/'Your PHP installation appears to be missing the MySQL extension which is required by WordPress.'/*/WP_I18N_OLD_MYSQL*/ );
  111
+	if ( ! extension_loaded( 'mysql' ) && ! file_exists( WP_CONTENT_DIR . '/db.php' ) ) {
  112
+		wp_load_translations_early();
  113
+		wp_die( __( 'Your PHP installation appears to be missing the MySQL extension which is required by WordPress.' ) );
  114
+	}
116 115
 }
117 116
 
118 117
 /**
@@ -159,6 +158,8 @@ function wp_maintenance() {
159 158
 		die();
160 159
 	}
161 160
 
  161
+	wp_load_translations_early();
  162
+
162 163
 	$protocol = $_SERVER["SERVER_PROTOCOL"];
163 164
 	if ( 'HTTP/1.1' != $protocol && 'HTTP/1.0' != $protocol )
164 165
 		$protocol = 'HTTP/1.0';
@@ -170,11 +171,11 @@ function wp_maintenance() {
170 171
 	<html xmlns="http://www.w3.org/1999/xhtml">
171 172
 	<head>
172 173
 	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
173  
-		<title><?php echo /*WP_I18N_MAINTENANCE*/'Maintenance'/*/WP_I18N_MAINTENANCE*/; ?></title>
  174
+		<title><?php _e( 'Maintenance' ); ?></title>
174 175
 
175 176
 	</head>
176 177
 	<body>
177  
-		<h1><?php echo /*WP_I18N_MAINT_MSG*/'Briefly unavailable for scheduled maintenance. Check back in a minute.'/*/WP_I18N_MAINT_MSG*/; ?></h1>
  178
+		<h1><?php _e( 'Briefly unavailable for scheduled maintenance. Check back in a minute.' ); ?></h1>
178 179
 	</body>
179 180
 	</html>
180 181
 <?php
@@ -364,8 +365,10 @@ function wp_set_wpdb_vars() {
364 365
 
365 366
 	$prefix = $wpdb->set_prefix( $table_prefix );
366 367
 
367  
-	if ( is_wp_error( $prefix ) )
368  
-		wp_die( /*WP_I18N_BAD_PREFIX*/'<strong>ERROR</strong>: <code>$table_prefix</code> in <code>wp-config.php</code> can only contain numbers, letters, and underscores.'/*/WP_I18N_BAD_PREFIX*/ );
  368
+	if ( is_wp_error( $prefix ) ) {
  369
+		wp_load_translations_early();
  370
+		wp_die( __( '<strong>ERROR</strong>: <code>$table_prefix</code> in <code>wp-config.php</code> can only contain numbers, letters, and underscores.' ) );
  371
+	}
369 372
 }
370 373
 
371 374
 /**
@@ -649,3 +652,87 @@ function is_multisite() {
649 652
 
650 653
 	return false;
651 654
 }
  655
+
  656
+/**
  657
+ * Attempts an early load of translations.
  658
+ *
  659
+ * Used for errors encountered during the initial loading process, before the locale has been
  660
+ * properly detected and loaded.
  661
+ *
  662
+ * Designed for unusual load sequences (like setup-config.php) or for when the script will then
  663
+ * terminate with an error, otherwise there is a risk that a file can be double-included.
  664
+ *
  665
+ * @since 3.4.0
  666
+ * @access private
  667
+ */
  668
+function wp_load_translations_early() {
  669
+	global $text_direction, $wp_locale;
  670
+
  671
+	static $loaded = false;
  672
+	if ( $loaded )
  673
+		return;
  674
+	$loaded = true;
  675
+
  676
+	if ( function_exists( 'did_action' ) && did_action( 'init' ) )
  677
+		return;
  678
+
  679
+	// We need $wp_local_package
  680
+	require ABSPATH . WPINC . '/version.php';
  681
+
  682
+	// Translation and localization
  683
+	require_once ABSPATH . WPINC . '/pomo/mo.php';
  684
+	require_once ABSPATH . WPINC . '/l10n.php';
  685
+	require_once ABSPATH . WPINC . '/locale.php';
  686
+
  687
+	// General libraries
  688
+	require_once ABSPATH . WPINC . '/functions.php';
  689
+	require_once ABSPATH . WPINC . '/plugin.php';
  690
+
  691
+	$locales = $locations = array();
  692
+
  693
+	while ( true ) {
  694
+		if ( defined( 'WPLANG' ) ) {
  695
+			if ( '' == WPLANG )
  696
+				break;
  697
+			$locales[] = WPLANG;
  698
+		}
  699
+
  700
+		if ( isset( $wp_local_package ) )
  701
+			$locales[] = $wp_local_package;
  702
+
  703
+		if ( ! $locales )
  704
+			break;
  705
+
  706
+		if ( defined( 'WP_LANG_DIR' ) && @is_dir( WP_LANG_DIR ) )
  707
+			$locations[] = WP_LANG_DIR;
  708
+
  709
+		if ( defined( 'WP_CONTENT_DIR' ) && @is_dir( WP_CONTENT_DIR . '/languages' ) )
  710
+			$locations[] = WP_CONTENT_DIR . '/languages';
  711
+
  712
+		if ( @is_dir( ABSPATH . 'wp-content/languages' ) )
  713
+			$locations[] = ABSPATH . 'wp-content/languages';
  714
+
  715
+		if ( @is_dir( ABSPATH . WPINC . '/languages' ) )
  716
+			$locations[] = ABSPATH . WPINC . '/languages';
  717
+
  718
+		if ( ! $locations )
  719
+			break;
  720
+
  721
+		$locations = array_unique( $locations );
  722
+
  723
+		foreach ( $locales as $locale ) {
  724
+			foreach ( $locations as $location ) {
  725
+				if ( file_exists( $location . '/' . $locale . '.mo' ) ) {
  726
+					load_textdomain( 'default', $location . '/' . $locale . '.mo' );
  727
+					if ( WP_Locale::is_locale_rtl( $locale ) )
  728
+						$text_direction = 'rtl';
  729
+					break 2;
  730
+				}
  731
+			}
  732
+		}
  733
+
  734
+		break;
  735
+	}
  736
+
  737
+	$wp_locale = new WP_Locale();
  738
+}
7  wp-includes/locale.php
@@ -87,7 +87,7 @@ class WP_Locale {
87 87
 	/**
88 88
 	 * Locales which are known to be right-to-left.
89 89
 	 */
90  
-	private $rtl_locales = array( 'ar', 'ckb', 'fa_IR', 'he_IL', 'ug_CN', 'dv', 'fa_AF', 'ha', 'ps', 'uz_UZ', 'yi' );
  90
+	private static $rtl_locales = array( 'ar', 'ckb', 'fa_IR', 'he_IL', 'ug_CN', 'dv', 'fa_AF', 'ha', 'ps', 'uz_UZ', 'yi' );
91 91
 
92 92
 	/**
93 93
 	 * Sets up the translated strings and object properties.
@@ -183,7 +183,7 @@ function init() {
183 183
 		$this->number_format['decimal_point'] = ('number_format_decimal_point' == $trans) ? '.' : $trans;
184 184
 
185 185
 		// Locale-specific tweaks
186  
-		if ( in_array( get_locale(), $this->rtl_locales ) )
  186
+		if ( self::is_locale_rtl( get_locale() ) )
187 187
 			$this->text_direction = 'rtl';
188 188
 
189 189
 		// Import the $text_direction global.
@@ -333,6 +333,9 @@ function is_rtl() {
333 333
 		return 'rtl' == $this->text_direction;
334 334
 	}
335 335
 
  336
+	public static function is_locale_rtl( $locale ) {
  337
+		return in_array( $locale, self::$rtl_locales );
  338
+	}
336 339
 }
337 340
 
338 341
 /**
24  wp-includes/ms-load.php
@@ -211,10 +211,12 @@ function wpmu_current_site() {
211 211
 	}
212 212
 
213 213
 	// Still no dice.
  214
+	wp_load_translations_early();
  215
+
214 216
 	if ( 1 == count( $sites ) )
215  
-		wp_die( sprintf( /*WP_I18N_BLOG_DOESNT_EXIST*/'That site does not exist. Please try <a href="%s">%s</a>.'/*/WP_I18N_BLOG_DOESNT_EXIST*/, $sites[0]->domain . $sites[0]->path ) );
  217
+		wp_die( sprintf( __( 'That site does not exist. Please try <a href="%s">%s</a>.' ), 'http://' . $sites[0]->domain . $sites[0]->path ) );
216 218
 	else
217  
-		wp_die( /*WP_I18N_NO_SITE_DEFINED*/'No site defined on this host. If you are the owner of this site, please check <a href="http://codex.wordpress.org/Debugging_a_WordPress_Network">Debugging a WordPress Network</a> for help.'/*/WP_I18N_NO_SITE_DEFINED*/ );
  219
+		wp_die( __( 'No site defined on this host. If you are the owner of this site, please check <a href="http://codex.wordpress.org/Debugging_a_WordPress_Network">Debugging a WordPress Network</a> for help.' ) );
218 220
 }
219 221
 
220 222
 /**
@@ -228,19 +230,21 @@ function wpmu_current_site() {
228 230
 function ms_not_installed() {
229 231
 	global $wpdb, $domain, $path;
230 232
 
231  
-	$title = /*WP_I18N_FATAL_ERROR*/'Error establishing database connection'/*/WP_I18N_FATAL_ERROR*/;
  233
+	wp_load_translations_early();
  234
+
  235
+	$title = __( 'Error establishing database connection' );
232 236
 	$msg  = '<h1>' . $title . '</h1>';
233 237
 	if ( ! is_admin() )
234 238
 		die( $msg );
235  
-	$msg .= '<p>' . /*WP_I18N_CONTACT_OWNER*/'If your site does not display, please contact the owner of this network.'/*/WP_I18N_CONTACT_OWNER*/ . '';
236  
-	$msg .= ' ' . /*WP_I18N_CHECK_MYSQL*/'If you are the owner of this network please check that MySQL is running properly and all tables are error free.'/*/WP_I18N_CHECK_MYSQL*/ . '</p>';
  239
+	$msg .= '<p>' . __( 'If your site does not display, please contact the owner of this network.' ) . '';
  240
+	$msg .= ' ' . __( 'If you are the owner of this network please check that MySQL is running properly and all tables are error free.' ) . '</p>';
237 241
 	if ( false && !$wpdb->get_var( "SHOW TABLES LIKE '$wpdb->site'" ) )
238  
-		$msg .= '<p>' . sprintf( /*WP_I18N_TABLES_MISSING_LONG*/'<strong>Database tables are missing.</strong> This means that MySQL is not running, WordPress was not installed properly, or someone deleted <code>%s</code>. You really should look at your database now.'/*/WP_I18N_TABLES_MISSING_LONG*/, $wpdb->site ) . '</p>';
  242
+		$msg .= '<p>' . sprintf( __( '<strong>Database tables are missing.</strong> This means that MySQL is not running, WordPress was not installed properly, or someone deleted <code>%s</code>. You really should look at your database now.' ), $wpdb->site ) . '</p>';
239 243
 	else
240  
-		$msg .= '<p>' . sprintf( /*WP_I18N_NO_SITE_FOUND*/'<strong>Could not find site <code>%1$s</code>.</strong> Searched for table <code>%2$s</code> in database <code>%3$s</code>. Is that right?'/*/WP_I18N_NO_SITE_FOUND*/, rtrim( $domain . $path, '/' ), $wpdb->blogs, DB_NAME ) . '</p>';
241  
-	$msg .= '<p><strong>' . /*WP_I18N_WHAT_DO_I_DO*/'What do I do now?'/*/WP_I18N_WHAT_DO_I_DO*/ . '</strong> ';
242  
-	$msg .= /*WP_I18N_RTFM*/'Read the <a target="_blank" href="http://codex.wordpress.org/Debugging_a_WordPress_Network">bug report</a> page. Some of the guidelines there may help you figure out what went wrong.'/*/WP_I18N_RTFM*/;
243  
-	$msg .= ' ' . /*WP_I18N_STUCK*/'If you&#8217;re still stuck with this message, then check that your database contains the following tables:'/*/WP_I18N_STUCK*/ . '</p><ul>';
  244
+		$msg .= '<p>' . sprintf( __( '<strong>Could not find site <code>%1$s</code>.</strong> Searched for table <code>%2$s</code> in database <code>%3$s</code>. Is that right?' ), rtrim( $domain . $path, '/' ), $wpdb->blogs, DB_NAME ) . '</p>';
  245
+	$msg .= '<p><strong>' . __( 'What do I do now?' ) . '</strong> ';
  246
+	$msg .= __( 'Read the <a target="_blank" href="http://codex.wordpress.org/Debugging_a_WordPress_Network">bug report</a> page. Some of the guidelines there may help you figure out what went wrong.' );
  247
+	$msg .= ' ' . __( 'If you&#8217;re still stuck with this message, then check that your database contains the following tables:' ) . '</p><ul>';
244 248
 	foreach ( $wpdb->tables('global') as $t => $table ) {
245 249
 		if ( 'sitecategories' == $t )
246 250
 			continue;
8  wp-includes/ms-settings.php
@@ -31,7 +31,8 @@
31 31
 			$domain = substr( $domain, 0, -4 );
32 32
 			$_SERVER['HTTP_HOST'] = substr( $_SERVER['HTTP_HOST'], 0, -4 );
33 33
 		} else {
34  
-			wp_die( /*WP_I18N_NO_PORT_NUMBER*/'Multisite only works without the port number in the URL.'/*/WP_I18N_NO_PORT_NUMBER*/ );
  34
+			wp_load_translations_early();
  35
+			wp_die( __( 'Multisite only works without the port number in the URL.' ) );
35 36
 		}
36 37
 	}
37 38
 
@@ -116,8 +117,9 @@
116 117
 		if ( defined( 'WP_INSTALLING' ) ) {
117 118
 			$current_blog->blog_id = $blog_id = 1;
118 119
 		} else {
119  
-			$msg = ! $wpdb->get_var( "SHOW TABLES LIKE '$wpdb->site'" ) ? ' ' . /*WP_I18N_TABLES_MISSING*/'Database tables are missing.'/*/WP_I18N_TABLES_MISSING*/ : '';
120  
-			wp_die( /*WP_I18N_NO_BLOG*/'No site by that name on this system.'/*/WP_I18N_NO_BLOG*/ . $msg );
  120
+			wp_load_translations_early();
  121
+			$msg = ! $wpdb->get_var( "SHOW TABLES LIKE '$wpdb->site'" ) ? ' ' . __( 'Database tables are missing.' ) : '';
  122
+			wp_die( __( 'No site by that name on this system.' ) . $msg );
121 123
 		}
122 124
 	}
123 125
 }
23  wp-includes/wp-db.php
@@ -573,7 +573,7 @@ function set_charset($dbh, $charset = null, $collate = null) {
573 573
 	function set_prefix( $prefix, $set_table_names = true ) {
574 574
 
575 575
 		if ( preg_match( '|[^a-z0-9_]|i', $prefix ) )
576  
-			return new WP_Error('invalid_db_prefix', /*WP_I18N_DB_BAD_PREFIX*/'Invalid database prefix'/*/WP_I18N_DB_BAD_PREFIX*/);
  576
+			return new WP_Error('invalid_db_prefix', 'Invalid database prefix' );
577 577
 
578 578
 		$old_prefix = is_multisite() ? '' : $prefix;
579 579
 
@@ -745,14 +745,15 @@ function select( $db, $dbh = null ) {
745 745
 
746 746
 		if ( !@mysql_select_db( $db, $dbh ) ) {
747 747
 			$this->ready = false;
748  
-			$this->bail( sprintf( /*WP_I18N_DB_SELECT_DB*/'<h1>Can&#8217;t select database</h1>
  748
+			wp_load_translations_early();
  749
+			$this->bail( sprintf( __( '<h1>Can&#8217;t select database</h1>
749 750
 <p>We were able to connect to the database server (which means your username and password is okay) but not able to select the <code>%1$s</code> database.</p>
750 751
 <ul>
751 752
 <li>Are you sure it exists?</li>
752 753
 <li>Does the user <code>%2$s</code> have permission to use the <code>%1$s</code> database?</li>
753 754
 <li>On some systems the name of your database is prefixed with your username, so it would be like <code>username_%1$s</code>. Could that be the problem?</li>
754 755
 </ul>
755  
-<p>If you don\'t know how to set up a database you should <strong>contact your host</strong>. If all else fails you may find help at the <a href="http://wordpress.org/support/">WordPress Support Forums</a>.</p>'/*/WP_I18N_DB_SELECT_DB*/, $db, $this->dbuser ), 'db_select_fail' );
  756
+<p>If you don\'t know how to set up a database you should <strong>contact your host</strong>. If all else fails you may find help at the <a href="http://wordpress.org/support/">WordPress Support Forums</a>.</p>' ), $db, $this->dbuser ), 'db_select_fail' );
756 757
 			return;
757 758
 		}
758 759
 	}
@@ -923,10 +924,12 @@ function print_error( $str = '' ) {
923 924
 		if ( $this->suppress_errors )
924 925
 			return false;
925 926
 
  927
+		wp_load_translations_early();
  928
+
926 929
 		if ( $caller = $this->get_caller() )
927  
-			$error_str = sprintf( /*WP_I18N_DB_QUERY_ERROR_FULL*/'WordPress database error %1$s for query %2$s made by %3$s'/*/WP_I18N_DB_QUERY_ERROR_FULL*/, $str, $this->last_query, $caller );
  930
+			$error_str = sprintf( __( 'WordPress database error %1$s for query %2$s made by %3$s' ), $str, $this->last_query, $caller );
928 931
 		else
929  
-			$error_str = sprintf( /*WP_I18N_DB_QUERY_ERROR*/'WordPress database error %1$s for query %2$s'/*/WP_I18N_DB_QUERY_ERROR*/, $str, $this->last_query );
  932
+			$error_str = sprintf( __( 'WordPress database error %1$s for query %2$s' ), $str, $this->last_query );
930 933
 
931 934
 		if ( function_exists( 'error_log' )
932 935
 			&& ( $log_file = @ini_get( 'error_log' ) )
@@ -1037,7 +1040,8 @@ function db_connect() {
1037 1040
 		}
1038 1041
 
1039 1042
 		if ( !$this->dbh ) {
1040  
-			$this->bail( sprintf( /*WP_I18N_DB_CONN_ERROR*/"
  1043
+			wp_load_translations_early();
  1044
+			$this->bail( sprintf( __( "
1041 1045
 <h1>Error establishing a database connection</h1>
1042 1046
 <p>This either means that the username and password information in your <code>wp-config.php</code> file is incorrect or we can't contact the database server at <code>%s</code>. This could mean your host's database server is down.</p>
1043 1047
 <ul>
@@ -1046,7 +1050,7 @@ function db_connect() {
1046 1050
 	<li>Are you sure that the database server is running?</li>
1047 1051
 </ul>
1048 1052
 <p>If you're unsure what these terms mean you should probably contact your host. If you still need help you can always visit the <a href='http://wordpress.org/support/'>WordPress Support Forums</a>.</p>
1049  
-"/*/WP_I18N_DB_CONN_ERROR*/, $this->dbhost ), 'db_connect_fail' );
  1053
+" ), $this->dbhost ), 'db_connect_fail' );
1050 1054
 
1051 1055
 			return;
1052 1056
 		}
@@ -1073,8 +1077,7 @@ function query( $query ) {
1073 1077
 			return false;
1074 1078
 
1075 1079
 		// some queries are made before the plugins have been loaded, and thus cannot be filtered with this method
1076  
-		if ( function_exists( 'apply_filters' ) )
1077  
-			$query = apply_filters( 'query', $query );
  1080
+		$query = apply_filters( 'query', $query );
1078 1081
 
1079 1082
 		$return_val = 0;
1080 1083
 		$this->flush();
@@ -1326,7 +1329,7 @@ function get_row( $query = null, $output = OBJECT, $y = 0 ) {
1326 1329
 		} elseif ( $output == ARRAY_N ) {
1327 1330
 			return $this->last_result[$y] ? array_values( get_object_vars( $this->last_result[$y] ) ) : null;
1328 1331
 		} else {
1329  
-			$this->print_error(/*WP_I18N_DB_GETROW_ERROR*/" \$db->get_row(string query, output type, int offset) -- Output type must be one of: OBJECT, ARRAY_A, ARRAY_N"/*/WP_I18N_DB_GETROW_ERROR*/);
  1332
+			$this->print_error( " \$db->get_row(string query, output type, int offset) -- Output type must be one of: OBJECT, ARRAY_A, ARRAY_N" );
1330 1333
 		}
1331 1334
 	}
1332 1335
 
22  wp-load.php
@@ -39,21 +39,23 @@
39 39
 
40 40
 	// Set a path for the link to the installer
41 41
 	if ( strpos($_SERVER['PHP_SELF'], 'wp-admin') !== false )
42  
-		$path = '';
  42
+		$path = 'setup-config.php';
43 43
 	else
44  
-		$path = 'wp-admin/';
  44
+		$path = 'wp-admin/setup-config.php';
45 45
 
46  
-	require_once( ABSPATH . '/wp-includes/load.php' );
47  
-	require_once( ABSPATH . '/wp-includes/version.php' );
48  
-	define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' );
49 46
 	define( 'WPINC', 'wp-includes' );
  47
+	define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' );
  48
+	require_once( ABSPATH . WPINC . '/load.php' );
  49
+	require_once( ABSPATH . WPINC . '/version.php' );
  50
+
  51
+	wp_load_translations_early();
50 52
 	wp_check_php_mysql_versions();
51 53
 
52 54
 	// Die with an error message
53  
-	require_once( ABSPATH . '/wp-includes/class-wp-error.php' );
54  
-	require_once( ABSPATH . '/wp-includes/functions.php' );
55  
-	require_once( ABSPATH . '/wp-includes/plugin.php' );
56  
-	$text_direction = /*WP_I18N_TEXT_DIRECTION*/'ltr'/*/WP_I18N_TEXT_DIRECTION*/;
57  
-	wp_die(sprintf(/*WP_I18N_NO_CONFIG*/"<p>There doesn't seem to be a <code>wp-config.php</code> file. I need this before we can get started.</p> <p>Need more help? <a href='http://codex.wordpress.org/Editing_wp-config.php'>We got it</a>.</p> <p>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='%ssetup-config.php' class='button'>Create a Configuration File</a></p>"/*/WP_I18N_NO_CONFIG*/, $path), /*WP_I18N_ERROR_TITLE*/'WordPress &rsaquo; Error'/*/WP_I18N_ERROR_TITLE*/, array('text_direction' => $text_direction));
  55
+	$die  = '<p>' . __( "There doesn't seem to be a <code>wp-config.php</code> file. I need this before we can get started." ) . '</p>';
  56
+	$die .= '<p>' . __( "Need more help? <a href='http://codex.wordpress.org/Editing_wp-config.php'>We got it</a>." ) . '</p>';
  57
+	$die .= '<p>' . __( "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>';
  58
+	$die .= '<p><a href="' . $path . '" class="button">' . __( "Create a Configuration File" ) . '</a></p>';
58 59
 
  60
+	wp_die( $die, __( 'WordPress &rsaquo; Error' ) );
59 61
 }
8  wp-settings.php
@@ -70,6 +70,7 @@
70 70
 require( ABSPATH . WPINC . '/class-wp.php' );
71 71
 require( ABSPATH . WPINC . '/class-wp-error.php' );
72 72
 require( ABSPATH . WPINC . '/plugin.php' );
  73
+require( ABSPATH . WPINC . '/pomo/mo.php' );
73 74
 
74 75
 // Include the wpdb class and, if present, a db.php database drop-in.
75 76
 require_wp_db();
@@ -81,9 +82,8 @@
81 82
 // Start the WordPress object cache, or an external object cache if the drop-in is present.
82 83
 wp_start_object_cache();
83 84
 
84  
-// Load early WordPress files.
  85
+// Attach the default filters.
85 86
 require( ABSPATH . WPINC . '/default-filters.php' );
86  
-require( ABSPATH . WPINC . '/pomo/mo.php' );
87 87
 
88 88
 // Initialize multisite if enabled.
89 89
 if ( is_multisite() ) {
@@ -100,7 +100,7 @@
100 100
 	return false;
101 101
 
102 102
 // Load the L10n library.
103  
-require( ABSPATH . WPINC . '/l10n.php' );
  103
+require_once( ABSPATH . WPINC . '/l10n.php' );
104 104
 
105 105
 // Run the installer if WordPress is not installed.
106 106
 wp_not_installed();
@@ -268,7 +268,7 @@
268 268
 unset($locale_file);
269 269
 
270 270
 // Pull in locale data after loading text domain.
271  
-require( ABSPATH . WPINC . '/locale.php' );
  271
+require_once( ABSPATH . WPINC . '/locale.php' );
272 272
 
273 273
 /**
274 274
  * WordPress Locale object for loading locale domain date and various strings.

0 notes on commit 81ed9a7

Please sign in to comment.
Something went wrong with that request. Please try again.