diff options
author | Peter Wilson <peterwilsoncc@git.wordpress.org> | 2024-02-18 22:14:04 +0000 |
---|---|---|
committer | Peter Wilson <peterwilsoncc@git.wordpress.org> | 2024-02-18 22:14:04 +0000 |
commit | de1ed9c57b1d2c00abaa0e473bec6979595489c3 (patch) | |
tree | d31c45817bb765523e7420c59f8a5159306fa75c /src/js/_enqueues/admin | |
parent | a9ba7fde796a2f343bb2acc10fddaaac40264ee3 (diff) | |
download | wordpress-de1ed9c57b1d2c00abaa0e473bec6979595489c3.tar.gz wordpress-de1ed9c57b1d2c00abaa0e473bec6979595489c3.zip |
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 #48244.
git-svn-id: https://develop.svn.wordpress.org/trunk@57654 602fd350-edb4-49c9-b593-d223f7449a82
Diffstat (limited to 'src/js/_enqueues/admin')
-rw-r--r-- | src/js/_enqueues/admin/common.js | 15 | ||||
-rw-r--r-- | src/js/_enqueues/admin/tags-suggest.js | 23 |
2 files changed, 28 insertions, 10 deletions
diff --git a/src/js/_enqueues/admin/common.js b/src/js/_enqueues/admin/common.js index 3de9447879..da7a7a3b07 100644 --- a/src/js/_enqueues/admin/common.js +++ b/src/js/_enqueues/admin/common.js @@ -354,6 +354,21 @@ window.setPostThumbnailL10n = window.setPostThumbnailL10n || { window.setPostThumbnailL10n = deprecateL10nObject( 'setPostThumbnailL10n', window.setPostThumbnailL10n, '5.5.0' ); /** + * 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' ); + +/** * Removed in 3.3.0, needed for back-compatibility. * * @since 2.7.0 diff --git a/src/js/_enqueues/admin/tags-suggest.js b/src/js/_enqueues/admin/tags-suggest.js index f93396a77e..d439f06ef0 100644 --- a/src/js/_enqueues/admin/tags-suggest.js +++ b/src/js/_enqueues/admin/tags-suggest.js @@ -4,12 +4,11 @@ * @output wp-admin/js/tags-suggest.js */ ( function( $ ) { - if ( typeof window.uiAutocompleteL10n === 'undefined' ) { - return; - } - var tempID = 0; var separator = wp.i18n._x( ',', 'tag delimiter' ) || ','; + var __ = wp.i18n.__, + _n = wp.i18n._n, + sprintf = wp.i18n.sprintf; function split( val ) { return val.split( new RegExp( separator + '\\s*' ) ); @@ -139,13 +138,17 @@ collision: 'none' }, messages: { - noResults: window.uiAutocompleteL10n.noResults, + noResults: __( 'No results found.' ), results: function( number ) { - if ( number > 1 ) { - return window.uiAutocompleteL10n.manyResults.replace( '%d', number ); - } - - return window.uiAutocompleteL10n.oneResult; + 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 + ); } } }, options ); |