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.

git-svn-id: https://develop.svn.wordpress.org/trunk@47884 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Dominik Schilling
2020-06-01 21:39:30 +00:00
parent 5263a96a4c
commit 9bea5b3444
3 changed files with 323 additions and 202 deletions

View File

@@ -1434,100 +1434,12 @@ function wp_default_scripts( $scripts ) {
);
$scripts->add( 'updates', "/wp-admin/js/updates$suffix.js", array( 'jquery', 'wp-util', 'wp-a11y', 'wp-sanitize' ), false, 1 );
$scripts->set_translations( 'updates' );
did_action( 'init' ) && $scripts->localize(
'updates',
'_wpUpdatesSettings',
array(
'ajax_nonce' => wp_create_nonce( 'updates' ),
'l10n' => array(
/* translators: %s: Search query. */
'searchResults' => __( 'Search results for “%s”' ),
'searchResultsLabel' => __( 'Search Results' ),
'noPlugins' => __( 'You do not appear to have any plugins available at this time.' ),
'noItemsSelected' => __( 'Please select at least one item to perform this action on.' ),
'updating' => __( 'Updating...' ), // No ellipsis.
'pluginUpdated' => _x( 'Updated!', 'plugin' ),
'themeUpdated' => _x( 'Updated!', 'theme' ),
'update' => __( 'Update' ),
'updateNow' => __( 'Update Now' ),
/* translators: %s: Plugin name and version. */
'pluginUpdateNowLabel' => _x( 'Update %s now', 'plugin' ),
'updateFailedShort' => __( 'Update Failed!' ),
/* translators: %s: Error string for a failed update. */
'updateFailed' => __( 'Update Failed: %s' ),
/* translators: %s: Plugin name and version. */
'pluginUpdatingLabel' => _x( 'Updating %s...', 'plugin' ), // No ellipsis.
/* translators: %s: Plugin name and version. */
'pluginUpdatedLabel' => _x( '%s updated!', 'plugin' ),
/* translators: %s: Plugin name and version. */
'pluginUpdateFailedLabel' => _x( '%s update failed', 'plugin' ),
/* translators: Accessibility text. */
'updatingMsg' => __( 'Updating... please wait.' ), // No ellipsis.
/* translators: Accessibility text. */
'updatedMsg' => __( 'Update completed successfully.' ),
/* translators: Accessibility text. */
'updateCancel' => __( 'Update canceled.' ),
'beforeunload' => __( 'Updates may not complete if you navigate away from this page.' ),
'installNow' => __( 'Install Now' ),
/* translators: %s: Plugin name. */
'pluginInstallNowLabel' => _x( 'Install %s now', 'plugin' ),
'installing' => __( 'Installing...' ),
'pluginInstalled' => _x( 'Installed!', 'plugin' ),
'themeInstalled' => _x( 'Installed!', 'theme' ),
'installFailedShort' => __( 'Installation Failed!' ),
/* translators: %s: Error string for a failed installation. */
'installFailed' => __( 'Installation failed: %s' ),
/* translators: %s: Plugin name and version. */
'pluginInstallingLabel' => _x( 'Installing %s...', 'plugin' ), // No ellipsis.
/* translators: %s: Theme name and version. */
'themeInstallingLabel' => _x( 'Installing %s...', 'theme' ), // No ellipsis.
/* translators: %s: Plugin name and version. */
'pluginInstalledLabel' => _x( '%s installed!', 'plugin' ),
/* translators: %s: Theme name and version. */
'themeInstalledLabel' => _x( '%s installed!', 'theme' ),
/* translators: %s: Plugin name and version. */
'pluginInstallFailedLabel' => _x( '%s installation failed', 'plugin' ),
/* translators: %s: Theme name and version. */
'themeInstallFailedLabel' => _x( '%s installation failed', 'theme' ),
'installingMsg' => __( 'Installing... please wait.' ),
'installedMsg' => __( 'Installation completed successfully.' ),
/* translators: %s: Activation URL. */
'importerInstalledMsg' => __( 'Importer installed successfully. <a href="%s">Run importer</a>' ),
/* translators: %s: Theme name. */
'aysDelete' => __( 'Are you sure you want to delete %s?' ),
/* translators: %s: Plugin name. */
'aysDeleteUninstall' => __( 'Are you sure you want to delete %s and its data?' ),
'aysBulkDelete' => __( 'Are you sure you want to delete the selected plugins and their data?' ),
'aysBulkDeleteThemes' => __( 'Caution: These themes may be active on other sites in the network. Are you sure you want to proceed?' ),
'deleting' => __( 'Deleting...' ),
/* translators: %s: Error string for a failed deletion. */
'deleteFailed' => __( 'Deletion failed: %s' ),
'pluginDeleted' => _x( 'Deleted!', 'plugin' ),
'themeDeleted' => _x( 'Deleted!', 'theme' ),
'livePreview' => __( 'Live Preview' ),
'activatePlugin' => is_network_admin() ? __( 'Network Activate' ) : __( 'Activate' ),
'activateTheme' => is_network_admin() ? __( 'Network Enable' ) : __( 'Activate' ),
/* translators: %s: Plugin name. */
'activatePluginLabel' => is_network_admin() ? _x( 'Network Activate %s', 'plugin' ) : _x( 'Activate %s', 'plugin' ),
/* translators: %s: Theme name. */
'activateThemeLabel' => is_network_admin() ? _x( 'Network Activate %s', 'theme' ) : _x( 'Activate %s', 'theme' ),
'activateImporter' => __( 'Run Importer' ),
/* translators: %s: Importer name. */
'activateImporterLabel' => __( 'Run %s' ),
'unknownError' => __( 'Something went wrong.' ),
'connectionError' => __( 'Connection lost or the server is busy. Please try again later.' ),
'nonceError' => __( 'An error has occurred. Please reload the page and try again.' ),
/* translators: %s: Number of plugins. */
'pluginsFound' => __( 'Number of plugins found: %d' ),
'noPluginsFound' => __( 'No plugins found. Try a different search.' ),
'autoUpdatesEnable' => __( 'Enable auto-updates' ),
'autoUpdatesEnabling' => __( 'Enabling...' ),
'autoUpdatesEnabled' => __( 'Auto-updates enabled' ),
'autoUpdatesDisable' => __( 'Disable auto-updates' ),
'autoUpdatesDisabling' => __( 'Disabling...' ),
'autoUpdatesDisabled' => __( 'Auto-updates disabled' ),
'autoUpdatesError' => __( 'The request could not be completed.' ),
),
)
);