Ticket #42725: add-new-gender-translation-function.diff
File add-new-gender-translation-function.diff, 2.1 KB (added by , 6 years ago) |
---|
-
tools/i18n/makepot.php
50 50 '__ngettext' => array('singular', 'plural'), 51 51 '__ngettext_noop' => array('singular', 'plural'), 52 52 '_x' => array('string', 'context'), 53 '_g' => array( 'string' ), 53 54 '_ex' => array('string', 'context'), 54 55 '_nx' => array('singular', 'plural', null, 'context'), 55 56 '_nx_noop' => array('singular', 'plural', 'context'), -
tools/i18n/extract.php
15 15 '_n' => array( 'singular', 'plural' ), 16 16 ); 17 17 var $comment_prefix = 'translators:'; 18 var $gender_context_prefix = '_wpg_'; 18 19 19 20 function __construct( $rules = array() ) { 20 21 $this->rules = $rules; … … 106 107 break; 107 108 } 108 109 } 110 111 if ( '_g' === $call['name'] ) { 112 $entry->context = isset( $entry->context ) ? $this->gender_context_prefix . $entry->context : $this->gender_context_prefix; 113 } 114 109 115 if ( isset( $call['line'] ) && $call['line'] ) { 110 116 $references = array( $file_name . ':' . $call['line'] ); 111 117 $entry->references = $references; -
src/wp-includes/l10n.php
292 292 * @return string Translated context string without pipe. 293 293 */ 294 294 function _x( $text, $context, $domain = 'default' ) { 295 //error_log( var_export( func_get_args() , true )); 295 296 return translate_with_gettext_context( $text, $context, $domain ); 296 297 } 297 298 299 function _g( $text, $gender = null, $domain ='default' ) { 300 if ( ! $gender ) { 301 $gender = get_current_user_gender(); 302 } 303 304 switch ( $gender ) { 305 case 'unknown': 306 return _x( $text, '_wpg_', $domain ); 307 case 'female': 308 return _x( $text, '_wpg_female_', $domain ); 309 case 'male': 310 return _x( $text, '_wpg_male_', $domain ); 311 } 312 } 313 298 314 /** 299 315 * Display translated string with gettext context. 300 316 *