Ticket #28577: 28577.4.patch
File 28577.4.patch, 3.3 KB (added by , 10 years ago) |
---|
-
src/wp-admin/includes/upgrade.php
2160 2160 endif; 2161 2161 2162 2162 function wp_install_language_form( $body ) { 2163 2163 2164 echo "<fieldset>\n"; 2164 2165 echo "<legend class='screen-reader-text'>Select a default language</legend>\n"; 2165 2166 echo '<input type="radio" checked="checked" class="screen-reader-input" name="language" id="language_default" value="">'; 2166 2167 echo '<label for="language_default">English (United States)</label>'; 2167 2168 echo "\n"; 2168 2169 2169 if ( defined( 'WPLANG' ) && ( '' !== WPLANG ) && ( 'en_US' !== WPLANG ) ) { 2170 $shown = array( 2171 'en_US' => true 2172 ); 2173 2174 if ( defined( 'WPLANG' ) && ( '' !== WPLANG ) && !isset( $shown[WPLANG] ) ) { 2170 2175 if ( isset( $body['languages'][WPLANG] ) ) { 2176 $shown[WPLANG] = true; 2171 2177 $language = $body['languages'][WPLANG]; 2172 2178 echo '<input type="radio" name="language" checked="checked" class="' . esc_attr( $language['language'] ) . ' screen-reader-input" id="language_wplang" value="' . esc_attr( $language['language'] ) . '">'; 2173 2179 echo '<label for="language_wplang">' . esc_html( $language['native_name'] ) . "</label>\n"; 2174 2180 } 2175 2181 } 2176 2182 2183 $top_accepted = false; 2184 foreach ( wp_get_browser_accepted_languages() as $accepted_language ) { 2185 2186 if ( isset( $shown[$accepted_language] ) ) { 2187 continue; 2188 } 2189 if ( isset( $body['languages'][$accepted_language] ) ) { 2190 $shown[$accepted_language] = true; 2191 $language = $body['languages'][$accepted_language]; 2192 echo '<input type="radio" name="language" ' . checked( $top_accepted, false, false ) . 'class="' . esc_attr( $language['language'] ) . ' screen-reader-input" id="language_accepted_' . esc_attr( $language['language'] ) . '" value="' . esc_attr( $language['language'] ) . '">'; 2193 echo '<label for="language_accepted_' . esc_attr( $language['language'] ) . '">' . esc_html( $language['native_name'] ) . "</label>\n"; 2194 } 2195 $top_accepted = $accepted_language; 2196 2197 } 2198 2177 2199 foreach ( $body['languages'] as $language ) { 2200 if ( isset( $shown[$language['language']] ) ) { 2201 continue; 2202 } 2178 2203 echo '<input type="radio" name="language" class="' . esc_attr( $language['language'] ) . ' screen-reader-input" id="language_'. esc_attr( $language['language'] ) .'" value="' . esc_attr( $language['language'] ) . '">'; 2179 2204 echo '<label for="language_' . esc_attr( $language['language'] ) . '">' . esc_html( $language['native_name'] ) . "</label>\n"; 2180 2205 } … … 2182 2207 echo '<p class="step"><input type="submit" class="button button-primary button-hero" value="»" /></p>'; 2183 2208 } 2184 2209 2210 function wp_get_browser_accepted_languages() { 2211 if ( empty( $_SERVER['HTTP_ACCEPT_LANGUAGE'] ) ) { 2212 return array(); 2213 } 2214 2215 $langs = explode( ',', $_SERVER['HTTP_ACCEPT_LANGUAGE'] ); 2216 $codes = array(); 2217 2218 foreach ( $langs as $lang ) { 2219 $lang = str_replace( '-', '_', trim( $lang ) ); 2220 if ( preg_match( '#^([^;]+);q=(0\.[0-9]{1,3})#', $lang, $m ) ) { 2221 $lang = $m[1]; 2222 $codes[$lang] = floatval( $m[2] ); 2223 } else { 2224 $codes[$lang] = 1.0; 2225 } 2226 } 2227 2228 arsort( $codes ); 2229 $accepted = array_keys( $codes ); 2230 return $accepted; 2231 2232 } 2233 2185 2234 /** 2186 * @todo rename, move 2235 * Get available languages from translations API 2236 * 2237 * @return boolean|array 2187 2238 */ 2188 2239 function wp_get_available_translations() { 2189 2240 $url = 'http://api.wordpress.org/translations/core/1.0/';