Make WordPress Core


Ignore:
Timestamp:
10/08/2015 04:51:50 PM (11 years ago)
Author:
SergeyBiryukov
Message:

Split database error messages into separate strings to remove unnecessary HTML tags from translations.

Add translator comments for placeholders.

Fixes #34216.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/wp-db.php

    r34737 r34942  
    10531053                        if ( ! did_action( 'template_redirect' ) ) {
    10541054                                wp_load_translations_early();
    1055                                 $this->bail( sprintf( __( '<h1>Can&#8217;t select database</h1>
    1056 <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>
    1057 <ul>
    1058 <li>Are you sure it exists?</li>
    1059 <li>Does the user <code>%2$s</code> have permission to use the <code>%1$s</code> database?</li>
    1060 <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>
    1061 </ul>
    1062 <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="https://wordpress.org/support/">WordPress Support Forums</a>.</p>' ), htmlspecialchars( $db, ENT_QUOTES ), htmlspecialchars( $this->dbuser, ENT_QUOTES ) ), 'db_select_fail' );
     1055
     1056                                $message = '<h1>' . __( 'Can&#8217;t select database' ) . "</h1>\n";
     1057
     1058                                $message .= '<p>' . sprintf(
     1059                                        /* translators: %s: database name */
     1060                                        __( 'We were able to connect to the database server (which means your username and password is okay) but not able to select the %s database.' ),
     1061                                        '<code>' . htmlspecialchars( $db, ENT_QUOTES ) . '</code>'
     1062                                ) . "</p>\n";
     1063
     1064                                $message .= "<ul>\n";
     1065                                $message .= '<li>' . __( 'Are you sure it exists?' ) . "</li>\n";
     1066
     1067                                $message .= '<li>' . sprintf(
     1068                                        /* translators: 1: database user, 2: database name */
     1069                                        __( 'Does the user %1$s have permission to use the %2$s database?' ),
     1070                                        '<code>' . htmlspecialchars( $this->dbuser, ENT_QUOTES )  . '</code>',
     1071                                        '<code>' . htmlspecialchars( $db, ENT_QUOTES ) . '</code>'
     1072                                ) . "</li>\n";
     1073
     1074                                $message .= '<li>' . sprintf(
     1075                                        /* translators: %s: database name */
     1076                                        __( '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?' ),
     1077                                        htmlspecialchars( $db, ENT_QUOTES )
     1078                                ). "</li>\n";
     1079
     1080                                $message .= "</ul>\n";
     1081
     1082                                $message .= '<p>' . sprintf(
     1083                                        /* translators: %s: support forums URL */
     1084                                        __( 'If you don&#8217;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="%s">WordPress Support Forums</a>.' ),
     1085                                        __( 'https://wordpress.org/support/' )
     1086                                ) . "</p>\n";
     1087
     1088                                $this->bail( $message, 'db_select_fail' );
    10631089                        }
    10641090                }
    … …  
    15041530                        }
    15051531
    1506                         $this->bail( sprintf( __( "
    1507 <h1>Error establishing a database connection</h1>
    1508 <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>
    1509 <ul>
    1510         <li>Are you sure you have the correct username and password?</li>
    1511         <li>Are you sure that you have typed the correct hostname?</li>
    1512         <li>Are you sure that the database server is running?</li>
    1513 </ul>
    1514 <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='https://wordpress.org/support/'>WordPress Support Forums</a>.</p>
    1515 " ), htmlspecialchars( $this->dbhost, ENT_QUOTES ) ), 'db_connect_fail' );
     1532                        $message = '<h1>' . __( 'Error establishing a database connection' ) . "</h1>\n";
     1533
     1534                        $message .= '<p>' . sprintf(
     1535                                /* translators: 1: wp-config.php. 2: database host */
     1536                                __( 'This either means that the username and password information in your %1$s file is incorrect or we can&#8217;t contact the database server at %2$s. This could mean your host&#8217;s database server is down.' ),
     1537                                '<code>wp-config.php</code>',
     1538                                '<code>' . htmlspecialchars( $this->dbhost, ENT_QUOTES ) . '</code>'
     1539                        ) . "</p>\n";
     1540
     1541                        $message .= "<ul>\n";
     1542                        $message .= '<li>' . __( 'Are you sure you have the correct username and password?' ) . "</li>\n";
     1543                        $message .= '<li>' . __( 'Are you sure that you have typed the correct hostname?' ) . "</li>\n";
     1544                        $message .= '<li>' . __( 'Are you sure that the database server is running?' ) . "</li>\n";
     1545                        $message .= "</ul>\n";
     1546
     1547                        $message .= '<p>' . sprintf(
     1548                                /* translators: %s: support forums URL */
     1549                                __( 'If you&#8217;re unsure what these terms mean you should probably contact your host. If you still need help you can always visit the <a href="%s">WordPress Support Forums</a>.' ),
     1550                                __( 'https://wordpress.org/support/' )
     1551                        ) . "</p>\n";
     1552
     1553                        $this->bail( $message, 'db_connect_fail' );
    15161554
    15171555                        return false;
    … …  
    15961634                }
    15971635
     1636                $message = '<h1>' . __( 'Error reconnecting to the database' ) . "</h1>\n";
     1637
     1638                $message .= '<p>' . sprintf(
     1639                        /* translators: %s: database host */
     1640                        __( 'This means that we lost contact with the database server at %s. This could mean your host&#8217;s database server is down.' ),
     1641                        '<code>' . htmlspecialchars( $this->dbhost, ENT_QUOTES ) . '</code>'
     1642                ) . "</p>\n";
     1643
     1644                $message .= "<ul>\n";
     1645                $message .= '<li>' . __( 'Are you sure that the database server is running?' ) . "</li>\n";
     1646                $message .= '<li>' . __( 'Are you sure that the database server is not under particularly heavy load?' ) . "</li>\n";
     1647                $message .= "</ul>\n";
     1648
     1649                $message .= '<p>' . sprintf(
     1650                        /* translators: %s: support forums URL */
     1651                        __( 'If you&#8217;re unsure what these terms mean you should probably contact your host. If you still need help you can always visit the <a href="%s">WordPress Support Forums</a>.' ),
     1652                        __( 'https://wordpress.org/support/' )
     1653                ) . "</p>\n";
     1654
    15981655                // We weren't able to reconnect, so we better bail.
    1599                 $this->bail( sprintf( ( "
    1600 <h1>Error reconnecting to the database</h1>
    1601 <p>This means that we lost contact with the database server at <code>%s</code>. This could mean your host's database server is down.</p>
    1602 <ul>
    1603         <li>Are you sure that the database server is running?</li>
    1604         <li>Are you sure that the database server is not under particularly heavy load?</li>
    1605 </ul>
    1606 <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='https://wordpress.org/support/'>WordPress Support Forums</a>.</p>
    1607 " ), htmlspecialchars( $this->dbhost, ENT_QUOTES ) ), 'db_connect_fail' );
     1656                $this->bail( $message, 'db_connect_fail' );
    16081657
    16091658                // Call dead_db() if bail didn't die, because this database is no more. It has ceased to be (at least temporarily).
Note: See TracChangeset for help on using the changeset viewer.