Skip to content

Commit 8c14a86

Browse files
committed
I18N: Namespace script module translation inline script IDs.
1 parent f8bd260 commit 8c14a86

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

src/wp-includes/class-wp-script-modules.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,9 +414,9 @@ public function print_script_module_translations(): void {
414414
wp_json_encode( $domain ),
415415
$json_translations
416416
);
417-
$source_url = rawurlencode( "{$id}-js-module-translations" );
417+
$source_url = rawurlencode( "wp-script-module-translation-data-{$id}" );
418418
$output .= "\n//# sourceURL={$source_url}";
419-
wp_print_inline_script_tag( $output, array( 'id' => "{$id}-js-module-translations" ) );
419+
wp_print_inline_script_tag( $output, array( 'id' => "wp-script-module-translation-data-{$id}" ) );
420420
}
421421
}
422422

tests/phpunit/tests/script-modules/wpScriptModules.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2744,7 +2744,7 @@ static function ( $relative, $src, $is_module ) use ( &$filtered ) {
27442744
$processor = new WP_HTML_Tag_Processor( $output );
27452745
$this->assertTrue( $processor->next_tag( 'SCRIPT' ) );
27462746
$script_text = $processor->get_modifiable_text();
2747-
$this->assertStringContainsString( 'test-module-js-module-translations', $script_text, 'Translation inline script should be printed with the expected ID.' );
2747+
$this->assertStringContainsString( 'wp-script-module-translation-data-test-module', $script_text, 'Translation inline script should be printed with the expected ID.' );
27482748
$this->assertStringContainsString( 'wp.i18n.setLocaleData', $script_text, 'Output should call wp.i18n.setLocaleData().' );
27492749
$this->assertStringContainsString( 'Hola', $script_text, 'Output should contain the translated string.' );
27502750
}
@@ -2811,7 +2811,7 @@ static function ( $relative, $src, $is_module ) use ( &$filtered ) {
28112811
$processor = new WP_HTML_Tag_Processor( $output );
28122812
$this->assertTrue( $processor->next_tag( 'SCRIPT' ) );
28132813
$script_text = $processor->get_modifiable_text();
2814-
$this->assertStringContainsString( 'dep-module-js-module-translations', $script_text, 'Dependency module translations should be printed.' );
2814+
$this->assertStringContainsString( 'wp-script-module-translation-data-dep-module', $script_text, 'Dependency module translations should be printed.' );
28152815
$this->assertStringContainsString( 'Mundo', $script_text, 'Output should contain the dependency translation.' );
28162816
}
28172817

0 commit comments

Comments
 (0)