diff --git a/wp-includes/l10n/class-wp-translation-file-mo.php b/wp-includes/l10n/class-wp-translation-file-mo.php index 225b48a836..bf39cc70ec 100644 --- a/wp-includes/l10n/class-wp-translation-file-mo.php +++ b/wp-includes/l10n/class-wp-translation-file-mo.php @@ -161,7 +161,15 @@ class WP_Translation_File_MO extends WP_Translation_File { $this->headers[ strtolower( $name ) ] = $value; } } else { - $this->entries[ (string) $original ] = $translation; + /* + * In MO files, the key normally contains both singular and plural versions. + * However, this just adds the singular string for lookup, + * which caters for cases where both __( 'Product' ) and _n( 'Product', 'Products' ) + * are used and the translation is expected to be the same for both. + */ + $parts = explode( "\0", (string) $original ); + + $this->entries[ $parts[0] ] = $translation; } } diff --git a/wp-includes/l10n/class-wp-translation-file-php.php b/wp-includes/l10n/class-wp-translation-file-php.php index 9f5b5abd98..f93dd0163f 100644 --- a/wp-includes/l10n/class-wp-translation-file-php.php +++ b/wp-includes/l10n/class-wp-translation-file-php.php @@ -28,12 +28,8 @@ class WP_Translation_File_PHP extends WP_Translation_File { } if ( isset( $result['messages'] ) && is_array( $result['messages'] ) ) { - foreach ( $result['messages'] as $singular => $translations ) { - if ( is_array( $translations ) ) { - $this->entries[ $singular ] = implode( "\0", $translations ); - } elseif ( is_string( $translations ) ) { - $this->entries[ $singular ] = $translations; - } + foreach ( $result['messages'] as $original => $translation ) { + $this->entries[ (string) $original ] = $translation; } unset( $result['messages'] ); } diff --git a/wp-includes/l10n/class-wp-translations.php b/wp-includes/l10n/class-wp-translations.php index 5992c855b6..e177e1d8c5 100644 --- a/wp-includes/l10n/class-wp-translations.php +++ b/wp-includes/l10n/class-wp-translations.php @@ -95,15 +95,10 @@ class WP_Translations { $entry->context = $parts[0]; } - // Look for plural original. - $parts = explode( "\0", $original ); - $entry->singular = $parts[0]; - if ( isset( $parts[1] ) ) { - $entry->is_plural = true; - $entry->plural = $parts[1]; - } - + $entry->singular = $original; $entry->translations = explode( "\0", $translations ); + $entry->is_plural = count( $entry->translations ) > 1; + return $entry; } diff --git a/wp-includes/version.php b/wp-includes/version.php index 1eb408e027..2753e3bee4 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.5-alpha-57512'; +$wp_version = '6.5-alpha-57513'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.