Make WordPress Core


Ignore:
Timestamp:
02/18/2024 10:14:04 PM (3 months ago)
Author:
peterwilsoncc
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/js/_enqueues/vendor/tinymce/plugins/wplink/plugin.js

    r47122 r57654  
    9999        var speak = ( typeof window.wp !== 'undefined' && window.wp.a11y && window.wp.a11y.speak ) ? window.wp.a11y.speak : function() {};
    100100        var hasLinkError = false;
     101        var __ = window.wp.i18n.__;
     102        var _n = window.wp.i18n._n;
     103        var sprintf = window.wp.i18n.sprintf;
    101104
    102105        function getSelectedLink() {
     
    458461                        },
    459462                        messages: {
    460                             noResults: ( typeof window.uiAutocompleteL10n !== 'undefined' ) ? window.uiAutocompleteL10n.noResults : '',
     463                            noResults: __( 'No results found.' ) ,
    461464                            results: function( number ) {
    462                                 if ( typeof window.uiAutocompleteL10n !== 'undefined' ) {
    463                                     if ( number > 1 ) {
    464                                         return window.uiAutocompleteL10n.manyResults.replace( '%d', number );
    465                                     }
    466 
    467                                     return window.uiAutocompleteL10n.oneResult;
    468                                 }
     465                                return sprintf(
     466                                    /* translators: %d: Number of search results found. */
     467                                    _n(
     468                                        '%d result found. Use up and down arrow keys to navigate.',
     469                                        '%d results found. Use up and down arrow keys to navigate.',
     470                                        number
     471                                    ),
     472                                    number
     473                                );
    469474                            }
    470475                        }
Note: See TracChangeset for help on using the changeset viewer.