I18N: Use underscores instead of dashes and interpolation instead of concatenation in domain-specific gettext hooks, per the coding standards:
* `gettext_{$domain}` * `gettext_with_context_{$domain}` * `ngettext_{$domain}` * `ngettext_with_context_{$domain}` Additionally: * Pass `$domain` parameter to the new hooks, for consistency with their pre-existing counterparts. * Update documentation to explain the dynamic portion of the filter, for consistency with other dynamic hooks in core. Follow-up to [48131]. Props swissspidy, knutsp, TimothyBlynJacobs, SergeyBiryukov. Fixes #49518. Built from https://develop.svn.wordpress.org/trunk@48136 git-svn-id: http://core.svn.wordpress.org/trunk@47905 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
07f71058c3
commit
69d46b2003
|
@ -129,6 +129,7 @@ function determine_locale() {
|
||||||
* @param string|null $locale The locale to return and short-circuit. Default null.
|
* @param string|null $locale The locale to return and short-circuit. Default null.
|
||||||
*/
|
*/
|
||||||
$determined_locale = apply_filters( 'pre_determine_locale', null );
|
$determined_locale = apply_filters( 'pre_determine_locale', null );
|
||||||
|
|
||||||
if ( ! empty( $determined_locale ) && is_string( $determined_locale ) ) {
|
if ( ! empty( $determined_locale ) && is_string( $determined_locale ) ) {
|
||||||
return $determined_locale;
|
return $determined_locale;
|
||||||
}
|
}
|
||||||
|
@ -181,21 +182,26 @@ function translate( $text, $domain = 'default' ) {
|
||||||
*
|
*
|
||||||
* @since 2.0.11
|
* @since 2.0.11
|
||||||
*
|
*
|
||||||
* @param string $translation Translated text.
|
* @param string $translation Translated text.
|
||||||
* @param string $text Text to translate.
|
* @param string $text Text to translate.
|
||||||
* @param string $domain Text domain. Unique identifier for retrieving translated strings.
|
* @param string $domain Text domain. Unique identifier for retrieving translated strings.
|
||||||
*/
|
*/
|
||||||
$translation = apply_filters( 'gettext', $translation, $text, $domain );
|
$translation = apply_filters( 'gettext', $translation, $text, $domain );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters text with its translation for a domain.
|
* Filters text with its translation for a domain.
|
||||||
*
|
*
|
||||||
|
* The dynamic portion of the hook, `$domain`, refers to the text domain.
|
||||||
|
*
|
||||||
* @since 5.5.0
|
* @since 5.5.0
|
||||||
*
|
*
|
||||||
* @param string $translation Translated text.
|
* @param string $translation Translated text.
|
||||||
* @param string $text Text to translate.
|
* @param string $text Text to translate.
|
||||||
|
* @param string $domain Text domain. Unique identifier for retrieving translated strings.
|
||||||
*/
|
*/
|
||||||
return apply_filters( 'gettext-' . $domain, $translation, $text );
|
$translation = apply_filters( "gettext_{$domain}", $translation, $text, $domain );
|
||||||
|
|
||||||
|
return $translation;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -243,23 +249,28 @@ function translate_with_gettext_context( $text, $context, $domain = 'default' )
|
||||||
*
|
*
|
||||||
* @since 2.8.0
|
* @since 2.8.0
|
||||||
*
|
*
|
||||||
* @param string $translation Translated text.
|
* @param string $translation Translated text.
|
||||||
* @param string $text Text to translate.
|
* @param string $text Text to translate.
|
||||||
* @param string $context Context information for the translators.
|
* @param string $context Context information for the translators.
|
||||||
* @param string $domain Text domain. Unique identifier for retrieving translated strings.
|
* @param string $domain Text domain. Unique identifier for retrieving translated strings.
|
||||||
*/
|
*/
|
||||||
$translation = apply_filters( 'gettext_with_context', $translation, $text, $context, $domain );
|
$translation = apply_filters( 'gettext_with_context', $translation, $text, $context, $domain );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters text with its translation based on context information for a domain.
|
* Filters text with its translation based on context information for a domain.
|
||||||
*
|
*
|
||||||
|
* The dynamic portion of the hook, `$domain`, refers to the text domain.
|
||||||
|
*
|
||||||
* @since 5.5.0
|
* @since 5.5.0
|
||||||
*
|
*
|
||||||
* @param string $translation Translated text.
|
* @param string $translation Translated text.
|
||||||
* @param string $text Text to translate.
|
* @param string $text Text to translate.
|
||||||
* @param string $context Context information for the translators.
|
* @param string $context Context information for the translators.
|
||||||
|
* @param string $domain Text domain. Unique identifier for retrieving translated strings.
|
||||||
*/
|
*/
|
||||||
return apply_filters( 'gettext_with_context-' . $domain, $translation, $text, $context );
|
$translation = apply_filters( "gettext_with_context_{$domain}", $translation, $text, $context, $domain );
|
||||||
|
|
||||||
|
return $translation;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -472,14 +483,19 @@ function _n( $single, $plural, $number, $domain = 'default' ) {
|
||||||
/**
|
/**
|
||||||
* Filters the singular or plural form of a string for a domain.
|
* Filters the singular or plural form of a string for a domain.
|
||||||
*
|
*
|
||||||
|
* The dynamic portion of the hook, `$domain`, refers to the text domain.
|
||||||
|
*
|
||||||
* @since 5.5.0
|
* @since 5.5.0
|
||||||
*
|
*
|
||||||
* @param string $translation Translated text.
|
* @param string $translation Translated text.
|
||||||
* @param string $single The text to be used if the number is singular.
|
* @param string $single The text to be used if the number is singular.
|
||||||
* @param string $plural The text to be used if the number is plural.
|
* @param string $plural The text to be used if the number is plural.
|
||||||
* @param string $number The number to compare against to use either the singular or plural form.
|
* @param string $number The number to compare against to use either the singular or plural form.
|
||||||
|
* @param string $domain Text domain. Unique identifier for retrieving translated strings.
|
||||||
*/
|
*/
|
||||||
return apply_filters( 'ngettext-' . $domain, $translation, $single, $plural, $number );
|
$translation = apply_filters( "ngettext_{$domain}", $translation, $single, $plural, $number, $domain );
|
||||||
|
|
||||||
|
return $translation;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -527,6 +543,8 @@ function _nx( $single, $plural, $number, $context, $domain = 'default' ) {
|
||||||
/**
|
/**
|
||||||
* Filters the singular or plural form of a string with gettext context for a domain.
|
* Filters the singular or plural form of a string with gettext context for a domain.
|
||||||
*
|
*
|
||||||
|
* The dynamic portion of the hook, `$domain`, refers to the text domain.
|
||||||
|
*
|
||||||
* @since 5.5.0
|
* @since 5.5.0
|
||||||
*
|
*
|
||||||
* @param string $translation Translated text.
|
* @param string $translation Translated text.
|
||||||
|
@ -534,8 +552,11 @@ function _nx( $single, $plural, $number, $context, $domain = 'default' ) {
|
||||||
* @param string $plural The text to be used if the number is plural.
|
* @param string $plural The text to be used if the number is plural.
|
||||||
* @param string $number The number to compare against to use either the singular or plural form.
|
* @param string $number The number to compare against to use either the singular or plural form.
|
||||||
* @param string $context Context information for the translators.
|
* @param string $context Context information for the translators.
|
||||||
|
* @param string $domain Text domain. Unique identifier for retrieving translated strings.
|
||||||
*/
|
*/
|
||||||
return apply_filters( 'ngettext_with_context-' . $domain, $translation, $single, $plural, $number, $context );
|
$translation = apply_filters( "ngettext_with_context_{$domain}", $translation, $single, $plural, $number, $context, $domain );
|
||||||
|
|
||||||
|
return $translation;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -691,7 +712,7 @@ function load_textdomain( $domain, $mofile ) {
|
||||||
*/
|
*/
|
||||||
$plugin_override = apply_filters( 'override_load_textdomain', false, $domain, $mofile );
|
$plugin_override = apply_filters( 'override_load_textdomain', false, $domain, $mofile );
|
||||||
|
|
||||||
if ( true == $plugin_override ) {
|
if ( true === (bool) $plugin_override ) {
|
||||||
unset( $l10n_unloaded[ $domain ] );
|
unset( $l10n_unloaded[ $domain ] );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '5.5-alpha-48135';
|
$wp_version = '5.5-alpha-48136';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue