diff --git a/src/js/_enqueues/wp/theme.js b/src/js/_enqueues/wp/theme.js index cfcea1fcc58b7..98dc490635ed2 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; /** * Announces to screen readers the theme shown after previous/next navigation. @@ -143,7 +142,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 ) { @@ -1005,9 +1004,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' ); @@ -1257,7 +1256,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++; @@ -1313,7 +1312,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(); } @@ -1400,9 +1399,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 ) ); } } }); @@ -1720,7 +1720,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' ); @@ -1852,7 +1853,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 8e6fc5d1eea2c..8a9c86367c4d3 100644 --- a/src/wp-admin/theme-install.php +++ b/src/wp-admin/theme-install.php @@ -80,6 +80,7 @@ ); 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 ac2cd4a9824cb..ab84510d03a52 100644 --- a/src/wp-admin/themes.php +++ b/src/wp-admin/themes.php @@ -245,6 +245,7 @@ add_thickbox(); wp_enqueue_script( 'theme' ); +wp_set_script_translations( 'theme' ); wp_enqueue_script( 'updates' ); require_once ABSPATH . 'wp-admin/admin-header.php';