Skip to content

Commit 5e33f4b

Browse files
committed
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
1 parent e26bbdb commit 5e33f4b

2 files changed

Lines changed: 1 addition & 22 deletions

File tree

src/wp-includes/l10n/class-wp-translation-file.php

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -203,24 +203,7 @@ public function translate( string $text ) {
203203
$this->parse_file();
204204
}
205205

206-
if ( isset( $this->entries[ $text ] ) ) {
207-
return $this->entries[ $text ];
208-
}
209-
210-
/*
211-
* Handle cases where a pluralized string is only used as a singular one.
212-
* For example, when both __( 'Product' ) and _n( 'Product', 'Products' )
213-
* are used, the entry key will have the format "ProductNULProducts".
214-
* Fall back to looking up just "Product" to support this edge case.
215-
*/
216-
foreach ( $this->entries as $key => $value ) {
217-
if ( str_starts_with( $key, $text . "\0" ) ) {
218-
$parts = explode( "\0", $value );
219-
return $parts[0];
220-
}
221-
}
222-
223-
return false;
206+
return $this->entries[ $text ] ?? false;
224207
}
225208

226209
/**

tests/phpunit/tests/l10n/wpTranslationsConvert.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,6 @@ public function test_simple_translation_files( string $file ) {
199199
$this->assertSame( 'translation1 with context', $controller->translate_plural( array( 'plural0 with context', 'plural1 with context' ), 0, 'context', 'unittest' ) );
200200
$this->assertSame( 'translation0 with context', $controller->translate_plural( array( 'plural0 with context', 'plural1 with context' ), 1, 'context', 'unittest' ) );
201201
$this->assertSame( 'translation1 with context', $controller->translate_plural( array( 'plural0 with context', 'plural1 with context' ), 2, 'context', 'unittest' ) );
202-
203-
$this->assertSame( 'Produkt', $controller->translate( 'Product', '', 'unittest' ) );
204-
$this->assertSame( 'Produkt', $controller->translate_plural( array( 'Product', 'Products' ), 1, '', 'unittest' ) );
205-
$this->assertSame( 'Produkte', $controller->translate_plural( array( 'Product', 'Products' ), 2, '', 'unittest' ) );
206202
}
207203

208204
/**

0 commit comments

Comments
 (0)