mirror of
git://develop.git.wordpress.org/
synced 2025-01-18 05:18:42 +01:00
I18N: Revert [57386] pending further investigation.
Reverts the change for fallback string lookup due to a performance regression in the bad case scenario. See #59656. git-svn-id: https://develop.svn.wordpress.org/trunk@57505 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
e26bbdbbf7
commit
5e33f4be2d
@ -203,24 +203,7 @@ abstract class WP_Translation_File {
|
||||
$this->parse_file();
|
||||
}
|
||||
|
||||
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;
|
||||
return $this->entries[ $text ] ?? false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -199,10 +199,6 @@ class WP_Translation_Controller_Convert_Tests extends WP_UnitTestCase {
|
||||
$this->assertSame( 'translation1 with context', $controller->translate_plural( array( 'plural0 with context', 'plural1 with context' ), 0, 'context', 'unittest' ) );
|
||||
$this->assertSame( 'translation0 with context', $controller->translate_plural( array( 'plural0 with context', 'plural1 with context' ), 1, 'context', 'unittest' ) );
|
||||
$this->assertSame( 'translation1 with context', $controller->translate_plural( array( 'plural0 with context', 'plural1 with context' ), 2, 'context', 'unittest' ) );
|
||||
|
||||
$this->assertSame( 'Produkt', $controller->translate( 'Product', '', 'unittest' ) );
|
||||
$this->assertSame( 'Produkt', $controller->translate_plural( array( 'Product', 'Products' ), 1, '', 'unittest' ) );
|
||||
$this->assertSame( 'Produkte', $controller->translate_plural( array( 'Product', 'Products' ), 2, '', 'unittest' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user