Changes in trunk/wp-includes/l10n.php [12257:12179]
- File:
-
- 1 edited
-
trunk/wp-includes/l10n.php (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/l10n.php
r12257 r12179 29 29 global $locale; 30 30 31 if ( isset( $locale ))31 if (isset($locale)) 32 32 return apply_filters( 'locale', $locale ); 33 33 34 34 // WPLANG is defined in wp-config. 35 if ( defined( 'WPLANG' ))35 if (defined('WPLANG')) 36 36 $locale = WPLANG; 37 37 38 if ( empty( $locale ))38 if (empty($locale)) 39 39 $locale = 'en_US'; 40 40 41 return apply_filters( 'locale', $locale);41 return apply_filters('locale', $locale); 42 42 } 43 43 … … 57 57 function translate( $text, $domain = 'default' ) { 58 58 $translations = &get_translations_for_domain( $domain ); 59 return apply_filters( 'gettext', $translations->translate( $text ), $text, $domain);59 return apply_filters('gettext', $translations->translate($text), $text, $domain); 60 60 } 61 61 … … 81 81 function translate_with_context( $text, $domain = 'default' ) { 82 82 return before_last_bar( translate( $text, $domain ) ); 83 83 84 } 84 85 85 86 function translate_with_gettext_context( $text, $context, $domain = 'default' ) { 86 87 $translations = &get_translations_for_domain( $domain ); 87 return apply_filters( 'gettext_with_context', $translations->translate( $text, $context ), $text, $context, $domain );88 return apply_filters( 'gettext_with_context', $translations->translate( $text, $context ), $text, $context, $domain); 88 89 } 89 90 … … 177 178 178 179 /** 179 * Retrieve translated string with gettextcontext180 * Retrieve translated string with vertical bar context 180 181 * 181 182 * Quite a few times, there will be collisions with similar translatable text 182 183 * found in more than two places but with different translated context. 183 184 * 184 * By including the context in the pot file translators can translate the two 185 * string differently 186 * 187 * @since 2.8 188 * 189 * @param string $text Text to translate 190 * @param string $context Context information for the translators 185 * In order to use the separate contexts, the _c() function is used and the 186 * translatable string uses a pipe ('|') which has the context the string is in. 187 * 188 * When the translated string is returned, it is everything before the pipe, not 189 * including the pipe character. If there is no pipe in the translated text then 190 * everything is returned. 191 * 192 * @since 2.2.0 193 * 194 * @param string $text Text to translate 191 195 * @param string $domain Optional. Domain to retrieve the translated text 192 196 * @return string Translated context string without pipe 193 197 */ 198 function _c($text, $domain = 'default') { 199 return translate_with_context($text, $domain); 200 } 194 201 195 202 function _x( $single, $context, $domain = 'default' ) { … … 199 206 function esc_attr_x( $single, $context, $domain = 'default' ) { 200 207 return esc_attr( translate_with_gettext_context( $single, $context, $domain ) ); 201 }202 203 function esc_html_x( $single, $context, $domain = 'default' ) {204 return esc_html( translate_with_gettext_context( $single, $context, $domain ) );205 208 } 206 209 … … 233 236 * @return string Either $single or $plural translated text 234 237 */ 235 function _n( $single, $plural, $number, $domain = 'default') {238 function _n($single, $plural, $number, $domain = 'default') { 236 239 $translations = &get_translations_for_domain( $domain ); 237 240 $translation = $translations->translate_plural( $single, $plural, $number ); … … 314 317 * @return bool true on success, false on failure 315 318 */ 316 function load_textdomain( $domain, $mofile) {319 function load_textdomain($domain, $mofile) { 317 320 global $l10n; 318 319 $plugin_override = apply_filters( 'override_load_textdomain', false, $domain, $mofile );320 321 if ( true == $plugin_override ) {322 return true;323 }324 325 do_action( 'load_textdomain', $domain, $mofile );326 327 $mofile = apply_filters( 'load_textdomain_mofile', $mofile, $domain );328 321 329 322 if ( !is_readable( $mofile ) ) return false; … … 336 329 337 330 $l10n[$domain] = &$mo; 338 339 331 return true; 340 332 } … … 353 345 $mofile = WP_LANG_DIR . "/$locale.mo"; 354 346 355 return load_textdomain( 'default', $mofile);347 return load_textdomain('default', $mofile); 356 348 } 357 349 … … 369 361 * @param string $plugin_rel_path Optional. Relative path to WP_PLUGIN_DIR. This is the preferred argument to use. It takes precendence over $abs_rel_path 370 362 */ 371 function load_plugin_textdomain( $domain, $abs_rel_path = false, $plugin_rel_path = false) {363 function load_plugin_textdomain($domain, $abs_rel_path = false, $plugin_rel_path = false) { 372 364 $locale = get_locale(); 373 365 374 366 if ( false !== $plugin_rel_path ) 375 $path = WP_PLUGIN_DIR . '/' . trim( $plugin_rel_path, '/' );376 else if ( false !== $abs_rel_path )377 $path = ABSPATH . trim( $abs_rel_path, '/' );367 $path = WP_PLUGIN_DIR . '/' . trim( $plugin_rel_path, '/'); 368 else if ( false !== $abs_rel_path) 369 $path = ABSPATH . trim( $abs_rel_path, '/'); 378 370 else 379 371 $path = WP_PLUGIN_DIR; 380 372 381 373 $mofile = $path . '/'. $domain . '-' . $locale . '.mo'; 382 return load_textdomain( $domain, $mofile);374 return load_textdomain($domain, $mofile); 383 375 } 384 376 … … 434 426 function &get_translations_for_domain( $domain ) { 435 427 global $l10n; 436 if ( !isset( $l10n[$domain]) ) {428 if ( !isset($l10n[$domain]) ) { 437 429 $l10n[$domain] = &new NOOP_Translations; 438 430 }
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)