Ticket #49518: 49518.2.diff
File 49518.2.diff, 5.3 KB (added by , 5 years ago) |
---|
-
src/wp-includes/l10n.php
165 165 * *Note:* Don't use translate() directly, use __() or related functions. 166 166 * 167 167 * @since 2.2.0 168 * @since 5.5.0 Introduced gettext-{$domain} filter. 168 169 * 169 170 * @param string $text Text to translate. 170 171 * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings. … … 175 176 $translations = get_translations_for_domain( $domain ); 176 177 $translation = $translations->translate( $text ); 177 178 179 178 180 /** 179 181 * Filters text with its translation. 180 182 * … … 184 186 * @param string $text Text to translate. 185 187 * @param string $domain Text domain. Unique identifier for retrieving translated strings. 186 188 */ 187 return apply_filters( 'gettext', $translation, $text, $domain ); 189 $translation = apply_filters( 'gettext', $translation, $text, $domain ); 190 191 /** 192 * Filters text with its translation for a domain. 193 * 194 * @since 5.5.0 195 * 196 * @param string $translation Translated text. 197 * @param string $text Text to translate. 198 */ 199 return apply_filters( 'gettext-' . $domain, $translation, $text ); 188 200 } 189 201 190 202 /** … … 215 227 * *Note:* Don't use translate_with_gettext_context() directly, use _x() or related functions. 216 228 * 217 229 * @since 2.8.0 230 * @since 5.5.0 Introduced gettext_with_context-{$domain} filter. 218 231 * 219 232 * @param string $text Text to translate. 220 233 * @param string $context Context information for the translators. … … 225 238 function translate_with_gettext_context( $text, $context, $domain = 'default' ) { 226 239 $translations = get_translations_for_domain( $domain ); 227 240 $translation = $translations->translate( $text, $context ); 241 228 242 /** 229 243 * Filters text with its translation based on context information. 230 244 * … … 235 249 * @param string $context Context information for the translators. 236 250 * @param string $domain Text domain. Unique identifier for retrieving translated strings. 237 251 */ 238 return apply_filters( 'gettext_with_context', $translation, $text, $context, $domain ); 252 $translation = apply_filters( 'gettext_with_context', $translation, $text, $context, $domain ); 253 254 /** 255 * Filters text with its translation based on context information for a domain. 256 * 257 * @since 5.5.0 258 * 259 * @param string $translation Translated text. 260 * @param string $text Text to translate. 261 * @param string $context Context information for the translators. 262 */ 263 return apply_filters( 'gettext_with_context-' . $domain, $translation, $text, $context ); 239 264 } 240 265 241 266 /** … … 419 444 * printf( _n( '%s person', '%s people', $count, 'text-domain' ), number_format_i18n( $count ) ); 420 445 * 421 446 * @since 2.8.0 447 * @since 5.5.0 Introduced ngettext-{$domain} filter. 422 448 * 423 449 * @param string $single The text to be used if the number is singular. 424 450 * @param string $plural The text to be used if the number is plural. … … 442 468 * @param string $number The number to compare against to use either the singular or plural form. 443 469 * @param string $domain Text domain. Unique identifier for retrieving translated strings. 444 470 */ 445 return apply_filters( 'ngettext', $translation, $single, $plural, $number, $domain ); 471 $translation = apply_filters( 'ngettext', $translation, $single, $plural, $number, $domain ); 472 473 /** 474 * Filters the singular or plural form of a string for a domain. 475 * 476 * @since 5.5.0 477 * 478 * @param string $translation Translated text. 479 * @param string $single The text to be used if the number is singular. 480 * @param string $plural The text to be used if the number is plural. 481 * @param string $number The number to compare against to use either the singular or plural form. 482 */ 483 return apply_filters( 'ngettext-' . $domain, $translation, $single, $plural, $number ); 446 484 } 447 485 448 486 /** … … 459 497 * printf( _nx( '%s group', '%s groups', $animals, 'group of animals', 'text-domain' ), number_format_i18n( $animals ) ); 460 498 * 461 499 * @since 2.8.0 500 * @since 5.5.0 Introduced ngettext_with_context-{$domain} filter. 462 501 * 463 502 * @param string $single The text to be used if the number is singular. 464 503 * @param string $plural The text to be used if the number is plural. … … 484 523 * @param string $context Context information for the translators. 485 524 * @param string $domain Text domain. Unique identifier for retrieving translated strings. 486 525 */ 487 return apply_filters( 'ngettext_with_context', $translation, $single, $plural, $number, $context, $domain ); 526 $translation = apply_filters( 'ngettext_with_context', $translation, $single, $plural, $number, $context, $domain ); 527 528 /** 529 * Filters the singular or plural form of a string with gettext context for a domain. 530 * 531 * @since 5.5.0 532 * 533 * @param string $translation Translated text. 534 * @param string $single The text to be used if the number is singular. 535 * @param string $plural The text to be used if the number is plural. 536 * @param string $number The number to compare against to use either the singular or plural form. 537 * @param string $context Context information for the translators. 538 */ 539 return apply_filters( 'ngettext_with_context-' . $domain, $translation, $single, $plural, $number, $context ); 488 540 } 489 541 490 542 /**