diff --git a/wp-includes/l10n/class-wp-translation-file.php b/wp-includes/l10n/class-wp-translation-file.php index 93842bec10..f920ab1388 100644 --- a/wp-includes/l10n/class-wp-translation-file.php +++ b/wp-includes/l10n/class-wp-translation-file.php @@ -203,7 +203,24 @@ abstract class WP_Translation_File { $this->parse_file(); } - return $this->entries[ $text ] ?? false; + if ( isset( $this->entries[ $text ] ) ) { + return $this->entries[ $text ]; + } + + /* + * Handle cases where a pluralized string is only used as a singular one. + * For example, when both __( 'Product' ) and _n( 'Product', 'Products' ) + * are used, the entry key will have the format "ProductNULProducts". + * Fall back to looking up just "Product" to support this edge case. + */ + foreach( $this->entries as $key => $value ) { + if ( str_starts_with( $key, $text . "\0" ) ) { + $parts = explode( "\0", $value ); + return $parts[0]; + } + } + + return false; } /** diff --git a/wp-includes/version.php b/wp-includes/version.php index 525b25e05f..21e4a2365e 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.5-alpha-57385'; +$wp_version = '6.5-alpha-57386'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.