Skip to content

Script Loader: Use localized list separators in dependency warning messages#10799

Closed
t-hamano wants to merge 2 commits intoWordPress:trunkfrom
t-hamano:64229-localize-separator
Closed

Script Loader: Use localized list separators in dependency warning messages#10799
t-hamano wants to merge 2 commits intoWordPress:trunkfrom
t-hamano:64229-localize-separator

Conversation

@t-hamano
Copy link
Copy Markdown
Contributor

@t-hamano t-hamano commented Jan 27, 2026

Trac ticket: https://core.trac.wordpress.org/ticket/64229


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Jan 27, 2026

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props wildworks, westonruter, jorbin, mukesh27.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions
Copy link
Copy Markdown

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • The Plugin and Theme Directories cannot be accessed within Playground.
  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

@t-hamano
Copy link
Copy Markdown
Contributor Author

How to test this PR

Switch the site locale to Japanese and enqueue a script with a non-existent dependency in an active theme. Example:

diff --git a/src/wp-content/themes/twentytwentyfive/functions.php b/src/wp-content/themes/twentytwentyfive/functions.php
index 8e4acf1e35..b30bdd93a5 100644
--- a/src/wp-content/themes/twentytwentyfive/functions.php
+++ b/src/wp-content/themes/twentytwentyfive/functions.php
@@ -157,3 +157,14 @@ if ( ! function_exists( 'twentytwentyfive_format_binding' ) ) :
                }
        }
 endif;
+
+add_action( 'wp_enqueue_scripts', function () {
+       wp_register_script(
+               'test-missing-deps',
+               includes_url( 'js/wp-embed.min.js' ),
+               array( 'non-existent-dependency-1', 'non-existent-dependency-2', 'non-existent-dependency-3' ),
+               null,
+               true
+       );
+       wp_enqueue_script( 'test-missing-deps' );
+} );

Then, open http://localhost:8889/

Make sure the separator is and not , . This character is a separator used in Japanese.

separator-ja

@mukeshpanchal27
Copy link
Copy Markdown
Member

Did some quick review and found same error for #10799 (comment) diff code.

Function WP_Scripts::add was called incorrectly. The script with the handle "test-missing-deps" was enqueued with dependencies that are not registered: non-existent-dependency-1、non-existent-dependency-2、non-existent-dependency-3. (This message was added in version 6.9.1.)

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates dependency warning messages across WordPress script and style loaders to use localized list separators instead of hardcoded comma-space separators. This allows different locales to format dependency lists according to their language conventions.

Changes:

  • Replaced hardcoded ', ' separators with wp_get_list_item_separator() function calls in dependency warning messages
  • Updated translator comments to reflect that the separators are now locale-aware

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
src/wp-includes/class-wp-dependencies.php Updated base class dependency warning message to use localized list separator
src/wp-includes/class-wp-scripts.php Updated script-specific dependency warning message to use localized list separator
src/wp-includes/class-wp-styles.php Updated style-specific dependency warning message to use localized list separator
src/wp-includes/class-wp-script-modules.php Updated script module dependency warning message to use localized list separator

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@t-hamano
Copy link
Copy Markdown
Contributor Author

This PR has been committed in https://core.trac.wordpress.org/changeset/61542

@t-hamano t-hamano closed this Jan 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants