Make WordPress Core


Ignore:
Timestamp:
06/01/2020 09:39:30 PM (6 years ago)
Author:
ocean90
Message:

I18N: Use wp.i18n for translatable strings in wp-admin/js/updates.js.

This removes the usage of wp_localize_script() for passing translations to the script and instead adds the translatable strings in the script directly through the use of wp.i18n and its utilities.

Props swissspidy, ocean90.
See #20491.
Fixes #50235.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/script-loader.php

    r47835 r47884  
    14351435
    14361436        $scripts->add( 'updates', "/wp-admin/js/updates$suffix.js", array( 'jquery', 'wp-util', 'wp-a11y', 'wp-sanitize' ), false, 1 );
     1437        $scripts->set_translations( 'updates' );
    14371438        did_action( 'init' ) && $scripts->localize(
    14381439            'updates',
     
    14401441            array(
    14411442                'ajax_nonce' => wp_create_nonce( 'updates' ),
    1442                 'l10n'       => array(
    1443                     /* translators: %s: Search query. */
    1444                     'searchResults'            => __( 'Search results for “%s”' ),
    1445                     'searchResultsLabel'       => __( 'Search Results' ),
    1446                     'noPlugins'                => __( 'You do not appear to have any plugins available at this time.' ),
    1447                     'noItemsSelected'          => __( 'Please select at least one item to perform this action on.' ),
    1448                     'updating'                 => __( 'Updating...' ), // No ellipsis.
    1449                     'pluginUpdated'            => _x( 'Updated!', 'plugin' ),
    1450                     'themeUpdated'             => _x( 'Updated!', 'theme' ),
    1451                     'update'                   => __( 'Update' ),
    1452                     'updateNow'                => __( 'Update Now' ),
    1453                     /* translators: %s: Plugin name and version. */
    1454                     'pluginUpdateNowLabel'     => _x( 'Update %s now', 'plugin' ),
    1455                     'updateFailedShort'        => __( 'Update Failed!' ),
    1456                     /* translators: %s: Error string for a failed update. */
    1457                     'updateFailed'             => __( 'Update Failed: %s' ),
    1458                     /* translators: %s: Plugin name and version. */
    1459                     'pluginUpdatingLabel'      => _x( 'Updating %s...', 'plugin' ), // No ellipsis.
    1460                     /* translators: %s: Plugin name and version. */
    1461                     'pluginUpdatedLabel'       => _x( '%s updated!', 'plugin' ),
    1462                     /* translators: %s: Plugin name and version. */
    1463                     'pluginUpdateFailedLabel'  => _x( '%s update failed', 'plugin' ),
    1464                     /* translators: Accessibility text. */
    1465                     'updatingMsg'              => __( 'Updating... please wait.' ), // No ellipsis.
    1466                     /* translators: Accessibility text. */
    1467                     'updatedMsg'               => __( 'Update completed successfully.' ),
    1468                     /* translators: Accessibility text. */
    1469                     'updateCancel'             => __( 'Update canceled.' ),
    1470                     'beforeunload'             => __( 'Updates may not complete if you navigate away from this page.' ),
    1471                     'installNow'               => __( 'Install Now' ),
    1472                     /* translators: %s: Plugin name. */
    1473                     'pluginInstallNowLabel'    => _x( 'Install %s now', 'plugin' ),
    1474                     'installing'               => __( 'Installing...' ),
    1475                     'pluginInstalled'          => _x( 'Installed!', 'plugin' ),
    1476                     'themeInstalled'           => _x( 'Installed!', 'theme' ),
    1477                     'installFailedShort'       => __( 'Installation Failed!' ),
    1478                     /* translators: %s: Error string for a failed installation. */
    1479                     'installFailed'            => __( 'Installation failed: %s' ),
    1480                     /* translators: %s: Plugin name and version. */
    1481                     'pluginInstallingLabel'    => _x( 'Installing %s...', 'plugin' ), // No ellipsis.
    1482                     /* translators: %s: Theme name and version. */
    1483                     'themeInstallingLabel'     => _x( 'Installing %s...', 'theme' ), // No ellipsis.
    1484                     /* translators: %s: Plugin name and version. */
    1485                     'pluginInstalledLabel'     => _x( '%s installed!', 'plugin' ),
    1486                     /* translators: %s: Theme name and version. */
    1487                     'themeInstalledLabel'      => _x( '%s installed!', 'theme' ),
    1488                     /* translators: %s: Plugin name and version. */
    1489                     'pluginInstallFailedLabel' => _x( '%s installation failed', 'plugin' ),
    1490                     /* translators: %s: Theme name and version. */
    1491                     'themeInstallFailedLabel'  => _x( '%s installation failed', 'theme' ),
    1492                     'installingMsg'            => __( 'Installing... please wait.' ),
    1493                     'installedMsg'             => __( 'Installation completed successfully.' ),
    1494                     /* translators: %s: Activation URL. */
    1495                     'importerInstalledMsg'     => __( 'Importer installed successfully. <a href="%s">Run importer</a>' ),
    1496                     /* translators: %s: Theme name. */
    1497                     'aysDelete'                => __( 'Are you sure you want to delete %s?' ),
    1498                     /* translators: %s: Plugin name. */
    1499                     'aysDeleteUninstall'       => __( 'Are you sure you want to delete %s and its data?' ),
    1500                     'aysBulkDelete'            => __( 'Are you sure you want to delete the selected plugins and their data?' ),
    1501                     'aysBulkDeleteThemes'      => __( 'Caution: These themes may be active on other sites in the network. Are you sure you want to proceed?' ),
    1502                     'deleting'                 => __( 'Deleting...' ),
    1503                     /* translators: %s: Error string for a failed deletion. */
    1504                     'deleteFailed'             => __( 'Deletion failed: %s' ),
    1505                     'pluginDeleted'            => _x( 'Deleted!', 'plugin' ),
    1506                     'themeDeleted'             => _x( 'Deleted!', 'theme' ),
    1507                     'livePreview'              => __( 'Live Preview' ),
    1508                     'activatePlugin'           => is_network_admin() ? __( 'Network Activate' ) : __( 'Activate' ),
    1509                     'activateTheme'            => is_network_admin() ? __( 'Network Enable' ) : __( 'Activate' ),
    1510                     /* translators: %s: Plugin name. */
    1511                     'activatePluginLabel'      => is_network_admin() ? _x( 'Network Activate %s', 'plugin' ) : _x( 'Activate %s', 'plugin' ),
    1512                     /* translators: %s: Theme name. */
    1513                     'activateThemeLabel'       => is_network_admin() ? _x( 'Network Activate %s', 'theme' ) : _x( 'Activate %s', 'theme' ),
    1514                     'activateImporter'         => __( 'Run Importer' ),
    1515                     /* translators: %s: Importer name. */
    1516                     'activateImporterLabel'    => __( 'Run %s' ),
    1517                     'unknownError'             => __( 'Something went wrong.' ),
    1518                     'connectionError'          => __( 'Connection lost or the server is busy. Please try again later.' ),
    1519                     'nonceError'               => __( 'An error has occurred. Please reload the page and try again.' ),
    1520                     /* translators: %s: Number of plugins. */
    1521                     'pluginsFound'             => __( 'Number of plugins found: %d' ),
    1522                     'noPluginsFound'           => __( 'No plugins found. Try a different search.' ),
    1523                     'autoUpdatesEnable'        => __( 'Enable auto-updates' ),
    1524                     'autoUpdatesEnabling'      => __( 'Enabling...' ),
    1525                     'autoUpdatesEnabled'       => __( 'Auto-updates enabled' ),
    1526                     'autoUpdatesDisable'       => __( 'Disable auto-updates' ),
    1527                     'autoUpdatesDisabling'     => __( 'Disabling...' ),
    1528                     'autoUpdatesDisabled'      => __( 'Auto-updates disabled' ),
    1529                     'autoUpdatesError'         => __( 'The request could not be completed.' ),
    1530                 ),
    15311443            )
    15321444        );
Note: See TracChangeset for help on using the changeset viewer.