Changeset 3559 for sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/routes/class-locale-banner.php
- Timestamp:
- 06/22/2016 04:06:56 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/routes/class-locale-banner.php
r3556 r3559 42 42 $all_locales = wp_list_pluck( $locale_subdomain_assoc, 'locale' ); 43 43 44 // Get the active language packs of the plugin. 45 $language_packs = $wpdb->get_results( $wpdb->prepare( " 46 SELECT * 47 FROM language_packs 48 WHERE 49 type = 'plugin' AND 50 domain = %s AND 51 active = 1 52 GROUP BY language", 53 $plugin_slug 54 ) ); 55 56 // Retrieve all the WordPress locales in which the plugin is translated. 57 $translated_locales = wp_list_pluck( $language_packs, 'language' ); 44 $is_plugin_request = ! empty( $plugin_slug ); 45 46 if ( $is_plugin_request ) { 47 // Get the active language packs of the plugin. 48 $language_packs = $wpdb->get_results( $wpdb->prepare( " 49 SELECT * 50 FROM language_packs 51 WHERE 52 type = 'plugin' AND 53 domain = %s AND 54 active = 1 55 GROUP BY language", 56 $plugin_slug 57 ) ); 58 59 // Retrieve all the WordPress locales in which the plugin is translated. 60 $translated_locales = wp_list_pluck( $language_packs, 'language' ); 61 } else { 62 $translated_locales = $all_locales; 63 } 58 64 59 65 // Get the WordPress locales based on the HTTP accept language header. … … 79 85 if ( 'en_US' === $current_locale ) { 80 86 if ( 1 === count( $suggest_named_locales ) ) { 81 $locale = key( $suggest_named_locales );87 $locale = key( $suggest_named_locales ); 82 88 $language = current( $suggest_named_locales ); 83 $suggest_string = sprintf( 84 $this->translate( 'This plugin is also available in %s.', $locale ), 85 sprintf( 86 '<a href="https://%s.wordpress.org/plugins-wp/%s/">%s</a>', 87 $locale_subdomain_assoc[ $locale ]->subdomain, 88 $plugin_slug, 89 $language 90 ) 91 ); 89 90 if ( $is_plugin_request ) { 91 $suggest_string = sprintf( 92 $this->translate( 'This plugin is also available in %s.', $locale ), 93 sprintf( 94 '<a href="https://%s.wordpress.org/plugins-wp/%s/">%s</a>', 95 $locale_subdomain_assoc[ $locale ]->subdomain, 96 $plugin_slug, 97 $language 98 ) 99 ); 100 } else { 101 $suggest_string = sprintf( 102 $this->translate( 'The plugin directory is also available in %s.', $locale ), 103 sprintf( 104 '<a href="https://%s.wordpress.org/plugins-wp/">%s</a>', 105 $locale_subdomain_assoc[ $locale ]->subdomain, 106 $language 107 ) 108 ); 109 } 92 110 } elseif ( ! empty( $suggest_named_locales ) ) { 93 111 $primary_locale = key( $suggest_named_locales ); … … 95 113 array_shift( $suggest_named_locales ); 96 114 97 $other_suggest = ''; 98 foreach ( $suggest_named_locales as $locale => $language ) { 99 $other_suggest .= sprintf( 100 '<a href="https://%s.wordpress.org/plugins-wp/%s/">%s</a>, ', 101 $locale_subdomain_assoc[ $locale ]->subdomain, 102 $plugin_slug, 103 $language 115 if ( $is_plugin_request ) { 116 $other_suggest = ''; 117 foreach ( $suggest_named_locales as $locale => $language ) { 118 $other_suggest .= sprintf( 119 '<a href="https://%s.wordpress.org/plugins-wp/%s/">%s</a>, ', 120 $locale_subdomain_assoc[ $locale ]->subdomain, 121 $plugin_slug, 122 $language 123 ); 124 } 125 126 $suggest_string = sprintf( 127 $this->translate( 'This plugin is also available in %1$s (also: %2$s).', $primary_locale ), 128 sprintf( 129 '<a href="https://%s.wordpress.org/plugins-wp/%s/">%s</a>', 130 $locale_subdomain_assoc[ $primary_locale ]->subdomain, 131 $plugin_slug, 132 $primary_language 133 ), 134 trim( $other_suggest, ' ,' ) 104 135 ); 105 } 106 107 $suggest_string = sprintf( 108 $this->translate( 'This plugin is also available in %1$s (also: %2$s).', $primary_locale ), 109 sprintf( 110 '<a href="https://%s.wordpress.org/plugins-wp/%s/">%s</a>', 111 $locale_subdomain_assoc[ $primary_locale ]->subdomain, 112 $plugin_slug, 113 $primary_language 114 ), 115 trim( $other_suggest, ' ,' ) 116 ); 117 } 118 } elseif ( ! $current_locale_is_suggested && ! $current_locale_is_translated ) { 136 } else { 137 $other_suggest = ''; 138 foreach ( $suggest_named_locales as $locale => $language ) { 139 $other_suggest .= sprintf( 140 '<a href="https://%s.wordpress.org/plugins-wp/">%s</a>, ', 141 $locale_subdomain_assoc[ $locale ]->subdomain, 142 $language 143 ); 144 } 145 146 $suggest_string = sprintf( 147 $this->translate( 'The plugin directory is also available in %1$s (also: %2$s).', $primary_locale ), 148 sprintf( 149 '<a href="https://%s.wordpress.org/plugins-wp/">%s</a>', 150 $locale_subdomain_assoc[ $primary_locale ]->subdomain, 151 $primary_language 152 ), 153 trim( $other_suggest, ' ,' ) 154 ); 155 } 156 } 157 } elseif ( ! $current_locale_is_suggested && ! $current_locale_is_translated && $is_plugin_request ) { 119 158 $suggest_string = sprintf( 120 159 $this->translate( 'This plugin is not available in %1$s yet. <a href="%2$s">Help translate it!</a>', $current_locale ), … … 248 287 2984794 => 'This plugin is also available in %1$s (also: %2$s).', 249 288 2984795 => 'This plugin is not available in %1$s yet. <a href="%2$s">Help translate it!</a>', 289 0 => 'The plugin directory is also available in %s.', 290 0 => 'The plugin directory is also available in %1$s (also: %2$s).', 250 291 ); 251 292 252 293 $original_id = array_search( $string, $strings, true ); 294 if ( ! $original_id ) { 295 return $string; 296 } 253 297 254 298 require_once GLOTPRESS_LOCALES_PATH; … … 311 355 /* translators: 1: native language name, 2: URL to translate.wordpress.org */ 312 356 __( 'This plugin is not available in %1$s yet. <a href="%2$s">Help translate it!</a>', 'wporg-plugins' ); 357 /* translators: %s: native language name. */ 358 __( 'The plugin directory is also available in %s.', 'wporg-plugins' ); 359 /* translators: 1: native language name, 2: other native language names, comma separated */ 360 __( 'The plugin directory is also available in %1$s (also: %2$s).', 'wporg-plugins' );
Note: See TracChangeset
for help on using the changeset viewer.