<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[57654] trunk/src: Script Loader: Switch to JavaScript translations.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/57654">57654</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/57654","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>peterwilsoncc</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2024-02-18 22:14:04 +0000 (Sun, 18 Feb 2024)</dd>
</dl>

<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Script Loader: Switch to JavaScript translations.

Update JavaScript files for tag suggestions and the TinyMCE link plugin to use client side translations. This allows for `_n()` to be used for strings requiring singular and plural versions in which the correct form is only known client side.

Props audrasjb, chaion07, costdev, hellofromtonya, johnbillion, marybaum, nicolefurlan, oglekler, rebasaurus, rsiddharth, sergeybiryukov, shaampk1, shahariaazam, swissspidy, tobifjellner.
Fixes <a href="https://core.trac.wordpress.org/ticket/48244">#48244</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcjs_enqueuesadmincommonjs">trunk/src/js/_enqueues/admin/common.js</a></li>
<li><a href="#trunksrcjs_enqueuesadmintagssuggestjs">trunk/src/js/_enqueues/admin/tags-suggest.js</a></li>
<li><a href="#trunksrcjs_enqueuesvendortinymcepluginswplinkpluginjs">trunk/src/js/_enqueues/vendor/tinymce/plugins/wplink/plugin.js</a></li>
<li><a href="#trunksrcwpincludesscriptloaderphp">trunk/src/wp-includes/script-loader.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcjs_enqueuesadmincommonjs"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/js/_enqueues/admin/common.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/js/_enqueues/admin/common.js    2024-02-18 18:59:24 UTC (rev 57653)
+++ trunk/src/js/_enqueues/admin/common.js      2024-02-18 22:14:04 UTC (rev 57654)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -354,6 +354,21 @@
</span><span class="cx" style="display: block; padding: 0 10px"> window.setPostThumbnailL10n = deprecateL10nObject( 'setPostThumbnailL10n', window.setPostThumbnailL10n, '5.5.0' );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Removed in 6.5.0, needed for back-compatibility.
+ *
+ * @since 4.5.0
+ * @deprecated 6.5.0
+ */
+window.uiAutocompleteL10n = window.uiAutocompleteL10n || {
+       noResults: '',
+       oneResult: '',
+       manyResults: '',
+       itemSelected: ''
+};
+
+window.uiAutocompleteL10n = deprecateL10nObject( 'uiAutocompleteL10n', window.uiAutocompleteL10n, '6.5.0' );
+
+/**
</ins><span class="cx" style="display: block; padding: 0 10px">  * Removed in 3.3.0, needed for back-compatibility.
</span><span class="cx" style="display: block; padding: 0 10px">  *
</span><span class="cx" style="display: block; padding: 0 10px">  * @since 2.7.0
</span></span></pre></div>
<a id="trunksrcjs_enqueuesadmintagssuggestjs"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/js/_enqueues/admin/tags-suggest.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/js/_enqueues/admin/tags-suggest.js      2024-02-18 18:59:24 UTC (rev 57653)
+++ trunk/src/js/_enqueues/admin/tags-suggest.js        2024-02-18 22:14:04 UTC (rev 57654)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4,12 +4,11 @@
</span><span class="cx" style="display: block; padding: 0 10px">  * @output wp-admin/js/tags-suggest.js
</span><span class="cx" style="display: block; padding: 0 10px">  */
</span><span class="cx" style="display: block; padding: 0 10px"> ( function( $ ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        if ( typeof window.uiAutocompleteL10n === 'undefined' ) {
-               return;
-       }
-
</del><span class="cx" style="display: block; padding: 0 10px">         var tempID = 0;
</span><span class="cx" style="display: block; padding: 0 10px">        var separator = wp.i18n._x( ',', 'tag delimiter' ) || ',';
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        var __ = wp.i18n.__,
+           _n = wp.i18n._n,
+           sprintf = wp.i18n.sprintf;
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        function split( val ) {
</span><span class="cx" style="display: block; padding: 0 10px">                return val.split( new RegExp( separator + '\\s*' ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -139,13 +138,17 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                collision: 'none'
</span><span class="cx" style="display: block; padding: 0 10px">                        },
</span><span class="cx" style="display: block; padding: 0 10px">                        messages: {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                noResults: window.uiAutocompleteL10n.noResults,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         noResults: __( 'No results found.' ),
</ins><span class="cx" style="display: block; padding: 0 10px">                                 results: function( number ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                        if ( number > 1 ) {
-                                               return window.uiAutocompleteL10n.manyResults.replace( '%d', number );
-                                       }
-
-                                       return window.uiAutocompleteL10n.oneResult;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                 return sprintf(
+                                               /* translators: %d: Number of search results found. */
+                                               _n(
+                                                       '%d result found. Use up and down arrow keys to navigate.',
+                                                       '%d results found. Use up and down arrow keys to navigate.',
+                                                       number
+                                               ),
+                                               number
+                                       );
</ins><span class="cx" style="display: block; padding: 0 10px">                                 }
</span><span class="cx" style="display: block; padding: 0 10px">                        }
</span><span class="cx" style="display: block; padding: 0 10px">                }, options );
</span></span></pre></div>
<a id="trunksrcjs_enqueuesvendortinymcepluginswplinkpluginjs"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/js/_enqueues/vendor/tinymce/plugins/wplink/plugin.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/js/_enqueues/vendor/tinymce/plugins/wplink/plugin.js    2024-02-18 18:59:24 UTC (rev 57653)
+++ trunk/src/js/_enqueues/vendor/tinymce/plugins/wplink/plugin.js      2024-02-18 22:14:04 UTC (rev 57654)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -98,6 +98,9 @@
</span><span class="cx" style="display: block; padding: 0 10px">                var urlRegex2 = /^https?:\/\/[^\/]+\.[^\/]+($|\/)/i;
</span><span class="cx" style="display: block; padding: 0 10px">                var speak = ( typeof window.wp !== 'undefined' && window.wp.a11y && window.wp.a11y.speak ) ? window.wp.a11y.speak : function() {};
</span><span class="cx" style="display: block; padding: 0 10px">                var hasLinkError = false;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                var __ = window.wp.i18n.__;
+               var _n = window.wp.i18n._n;
+               var sprintf = window.wp.i18n.sprintf;
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                function getSelectedLink() {
</span><span class="cx" style="display: block; padding: 0 10px">                        var href, html,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -457,15 +460,17 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                                        my: 'left top+2'
</span><span class="cx" style="display: block; padding: 0 10px">                                                },
</span><span class="cx" style="display: block; padding: 0 10px">                                                messages: {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                                        noResults: ( typeof window.uiAutocompleteL10n !== 'undefined' ) ? window.uiAutocompleteL10n.noResults : '',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                                 noResults: __( 'No results found.' ) ,
</ins><span class="cx" style="display: block; padding: 0 10px">                                                         results: function( number ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                                                if ( typeof window.uiAutocompleteL10n !== 'undefined' ) {
-                                                                       if ( number > 1 ) {
-                                                                               return window.uiAutocompleteL10n.manyResults.replace( '%d', number );
-                                                                       }
-
-                                                                       return window.uiAutocompleteL10n.oneResult;
-                                                               }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                                         return sprintf(
+                                                                       /* translators: %d: Number of search results found. */
+                                                                       _n(
+                                                                               '%d result found. Use up and down arrow keys to navigate.',
+                                                                               '%d results found. Use up and down arrow keys to navigate.',
+                                                                               number
+                                                                       ),
+                                                                       number
+                                                               );
</ins><span class="cx" style="display: block; padding: 0 10px">                                                         }
</span><span class="cx" style="display: block; padding: 0 10px">                                                }
</span><span class="cx" style="display: block; padding: 0 10px">                                        } ).autocomplete( 'instance' )._renderItem = function( ul, item ) {
</span></span></pre></div>
<a id="trunksrcwpincludesscriptloaderphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/script-loader.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/script-loader.php   2024-02-18 18:59:24 UTC (rev 57653)
+++ trunk/src/wp-includes/script-loader.php     2024-02-18 22:14:04 UTC (rev 57654)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -932,20 +932,6 @@
</span><span class="cx" style="display: block; padding: 0 10px">        $scripts->add( 'jquery-ui-position', false, array( 'jquery-ui-core' ), '1.13.2', 1 );
</span><span class="cx" style="display: block; padding: 0 10px">        $scripts->add( 'jquery-ui-widget', false, array( 'jquery-ui-core' ), '1.13.2', 1 );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        // Strings for 'jquery-ui-autocomplete' live region messages.
-       did_action( 'init' ) && $scripts->localize(
-               'jquery-ui-autocomplete',
-               'uiAutocompleteL10n',
-               array(
-                       'noResults'    => __( 'No results found.' ),
-                       /* translators: Number of results found when using jQuery UI Autocomplete. */
-                       'oneResult'    => __( '1 result found. Use up and down arrow keys to navigate.' ),
-                       /* translators: %d: Number of results found when using jQuery UI Autocomplete. */
-                       'manyResults'  => __( '%d results found. Use up and down arrow keys to navigate.' ),
-                       'itemSelected' => __( 'Item selected.' ),
-               )
-       );
-
</del><span class="cx" style="display: block; padding: 0 10px">         // Deprecated, not used in core, most functionality is included in jQuery 1.3.
</span><span class="cx" style="display: block; padding: 0 10px">        $scripts->add( 'jquery-form', "/wp-includes/js/jquery/jquery.form$suffix.js", array( 'jquery' ), '4.3.0', 1 );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1247,7 +1233,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        $scripts->add( 'admin-bar', "/wp-includes/js/admin-bar$suffix.js", array( 'hoverintent-js' ), false, 1 );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        $scripts->add( 'wplink', "/wp-includes/js/wplink$suffix.js", array( 'jquery', 'wp-a11y' ), false, 1 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $scripts->add( 'wplink', "/wp-includes/js/wplink$suffix.js", array( 'common', 'jquery', 'wp-a11y', 'wp-i18n' ), false, 1 );
+       $scripts->set_translations( 'wplink' );
</ins><span class="cx" style="display: block; padding: 0 10px">         did_action( 'init' ) && $scripts->localize(
</span><span class="cx" style="display: block; padding: 0 10px">                'wplink',
</span><span class="cx" style="display: block; padding: 0 10px">                'wpLinkL10n',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1425,7 +1412,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                $scripts->add( 'tags-box', "/wp-admin/js/tags-box$suffix.js", array( 'jquery', 'tags-suggest' ), false, 1 );
</span><span class="cx" style="display: block; padding: 0 10px">                $scripts->set_translations( 'tags-box' );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $scripts->add( 'tags-suggest', "/wp-admin/js/tags-suggest$suffix.js", array( 'jquery-ui-autocomplete', 'wp-a11y' ), false, 1 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $scripts->add( 'tags-suggest', "/wp-admin/js/tags-suggest$suffix.js", array( 'common', 'jquery-ui-autocomplete', 'wp-a11y', 'wp-i18n' ), false, 1 );
</ins><span class="cx" style="display: block; padding: 0 10px">                 $scripts->set_translations( 'tags-suggest' );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $scripts->add( 'post', "/wp-admin/js/post$suffix.js", array( 'suggest', 'wp-lists', 'postbox', 'tags-box', 'underscore', 'word-count', 'wp-a11y', 'wp-sanitize', 'clipboard' ), false, 1 );
</span></span></pre>
</div>
</div>

</body>
</html>