diff --git a/src/js/_enqueues/wp/theme.js b/src/js/_enqueues/wp/theme.js index 56107ee475057..f613e23c71318 100644 --- a/src/js/_enqueues/wp/theme.js +++ b/src/js/_enqueues/wp/theme.js @@ -8,13 +8,12 @@ window.wp = window.wp || {}; ( function($) { // Set up our namespace... -var themes, l10n; +var themes; themes = wp.themes = wp.themes || {}; // Store the theme data and settings for organized and quick access. -// themes.data.settings, themes.data.themes, themes.data.l10n. +// themes.data.settings, themes.data.themes. themes.data = _wpThemeSettings; -l10n = themes.data.l10n; // Shortcut for isInstall check. themes.isInstall = !! themes.data.settings.isInstall; @@ -119,7 +118,7 @@ themes.view.Appearance = wp.Backbone.View.extend({ view.render(); this.searchContainer .find( '.search-box' ) - .append( $.parseHTML( '' ) ) + .append( $.parseHTML( '' ) ) .append( view.el ); this.searchContainer.on( 'submit', function( event ) { @@ -973,9 +972,9 @@ themes.view.Preview = themes.view.Details.extend({ collapse: function( event ) { var $button = $( event.currentTarget ); if ( 'true' === $button.attr( 'aria-expanded' ) ) { - $button.attr({ 'aria-expanded': 'false', 'aria-label': l10n.expandSidebar }); + $button.attr({ 'aria-expanded': 'false', 'aria-label': wp.i18n.__( 'Expand Sidebar' ) }); } else { - $button.attr({ 'aria-expanded': 'true', 'aria-label': l10n.collapseSidebar }); + $button.attr({ 'aria-expanded': 'true', 'aria-label': wp.i18n.__( 'Collapse Sidebar' ) }); } this.$el.toggleClass( 'collapsed' ).toggleClass( 'expanded' ); @@ -1221,7 +1220,7 @@ themes.view.Themes = wp.Backbone.View.extend({ // 'Add new theme' element shown at the end of the grid. if ( ! themes.isInstall && themes.data.settings.canInstall ) { - this.$el.append( '

' + l10n.addNew + '

' ); + this.$el.append( '

' + wp.i18n.__( 'Add Theme' ) + '

' ); } this.parent.page++; @@ -1277,7 +1276,7 @@ themes.view.Themes = wp.Backbone.View.extend({ $modal.find( '.notice-warning' ) .removeClass( 'notice-large' ) .addClass( 'updating-message' ) - .find( 'p' ).text( wp.updates.l10n.updating ); + .find( 'p' ).text( wp.i18n.__( 'Updating...' ) ); } else if ( $card.find( '.notice-error' ).length ) { $modal.find( '.notice-warning' ).remove(); } @@ -1356,9 +1355,10 @@ themes.view.Themes = wp.Backbone.View.extend({ // Dispatch audible search results feedback message. announceSearchResults: function( count ) { if ( 0 === count ) { - wp.a11y.speak( l10n.noThemesFound ); + wp.a11y.speak( wp.i18n.__( 'No themes found. Try a different search.' ) ); } else { - wp.a11y.speak( l10n.themesFound.replace( '%d', count ) ); + /* translators: %d: Number of themes. */ + wp.a11y.speak( wp.i18n.sprintf( wp.i18n.__( 'Number of Themes found: %d' ), count ) ); } } }); @@ -1676,7 +1676,8 @@ themes.view.Installer = themes.view.Appearance.extend({ this.listenTo( this.collection, 'query:fail', function() { $( 'body' ).removeClass( 'loading-content' ); $( '.theme-browser' ).find( 'div.error' ).remove(); - $( '.theme-browser' ).find( 'div.themes' ).before( '

' + l10n.error + '

' ); + /* translators: %s: Support forums URL. */ + $( '.theme-browser' ).find( 'div.themes' ).before( '

' + wp.i18n.sprintf( wp.i18n.__( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the support forums.' ), 'https://wordpress.org/support/forums/' ) + '

' ); $( '.theme-browser .error .try-again' ).on( 'click', function( e ) { e.preventDefault(); $( 'input.wp-filter-search' ).trigger( 'input' ); @@ -1808,7 +1809,8 @@ themes.view.Installer = themes.view.Appearance.extend({ } if ( ! tags ) { - wp.a11y.speak( l10n.selectFeatureFilter ); + /* translators: Hidden accessibility text. */ + wp.a11y.speak( wp.i18n.__( 'Select one or more Theme features to filter by' ) ); return; } diff --git a/src/wp-admin/theme-install.php b/src/wp-admin/theme-install.php index e9d217c0f7525..aac20ea24cb63 100644 --- a/src/wp-admin/theme-install.php +++ b/src/wp-admin/theme-install.php @@ -53,31 +53,13 @@ 'installURI' => current_user_can( 'install_themes' ) ? self_admin_url( 'theme-install.php' ) : null, 'adminUrl' => parse_url( self_admin_url(), PHP_URL_PATH ), ), - 'l10n' => array( - 'addNew' => __( 'Add Theme' ), - 'search' => __( 'Search Themes' ), - 'upload' => __( 'Upload Theme' ), - 'back' => __( 'Back' ), - 'error' => sprintf( - /* translators: %s: Support forums URL. */ - __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the support forums.' ), - __( 'https://wordpress.org/support/forums/' ) - ), - 'tryAgain' => __( 'Try Again' ), - /* translators: %d: Number of themes. */ - 'themesFound' => __( 'Number of Themes found: %d' ), - 'noThemesFound' => __( 'No themes found. Try a different search.' ), - 'collapseSidebar' => __( 'Collapse Sidebar' ), - 'expandSidebar' => __( 'Expand Sidebar' ), - /* translators: Hidden accessibility text. */ - 'selectFeatureFilter' => __( 'Select one or more Theme features to filter by' ), - ), 'installedThemes' => array_keys( $installed_themes ), 'activeTheme' => get_stylesheet(), ) ); wp_enqueue_script( 'theme' ); +wp_set_script_translations( 'theme' ); wp_enqueue_script( 'updates' ); if ( $tab ) { diff --git a/src/wp-admin/themes.php b/src/wp-admin/themes.php index ca9f52b2a164f..096e869f7c316 100644 --- a/src/wp-admin/themes.php +++ b/src/wp-admin/themes.php @@ -230,18 +230,12 @@ 'confirmDelete' => __( "Are you sure you want to delete this theme?\n\nClick 'Cancel' to go back, 'OK' to confirm the delete." ), 'adminUrl' => parse_url( admin_url(), PHP_URL_PATH ), ), - 'l10n' => array( - 'addNew' => __( 'Add Theme' ), - 'search' => __( 'Search installed themes' ), - /* translators: %d: Number of themes. */ - 'themesFound' => __( 'Number of Themes found: %d' ), - 'noThemesFound' => __( 'No themes found. Try a different search.' ), - ), ) ); add_thickbox(); wp_enqueue_script( 'theme' ); +wp_set_script_translations( 'theme' ); wp_enqueue_script( 'updates' ); require_once ABSPATH . 'wp-admin/admin-header.php';