Changeset 12535
- Timestamp:
- 04/12/2023 08:05:53 PM (22 months 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
r11297 r12535 119 119 120 120 // Only one locale suggestion. 121 if ( 1 === count( $suggest_named_locales ) ) { 122 $locale = key( $suggest_named_locales ); 123 $language = current( $suggest_named_locales ); 121 if ( ! empty( $suggest_named_locales ) ) { 122 $primary_locale = key( $suggest_named_locales ); 123 // Load translations for wp_sprintf_l(). 124 add_filter( 'wp_sprintf_l', function( $translations ) use( $primary_locale ) { 125 $translations['between'] = sprintf( $this->translate( '%1$s, %2$s', $primary_locale ), '', '' ); 126 $translations['between_last_two'] = sprintf( $this->translate( '%1$s, and %2$s', $primary_locale ), '', '' ); 127 $translations['between_only_two'] = sprintf( $this->translate( '%1$s and %2$s', $primary_locale ), '', '' ); 128 129 return $translations; 130 } ); 131 132 $suggestions = array(); 133 foreach ( $suggest_named_locales as $locale => $language ) { 134 $suggestions[] = sprintf( 135 '<a href="https://%s.wordpress.org%s">%s</a>', 136 $locale_subdomain_assoc[ $locale ]->subdomain, 137 esc_url( $current_path ), 138 $language 139 ); 140 } 124 141 125 142 if ( $is_plugin_request ) { 126 143 $suggest_string = sprintf( 127 $this->translate( 'This plugin is also available in %1$s. <a href="%2$s">Help improve the translation!</a>', $locale ), 128 sprintf( 129 '<a href="https://%s.wordpress.org%s">%s</a>', 130 $locale_subdomain_assoc[ $locale ]->subdomain, 131 esc_url( $current_path ), 132 $language 133 ), 144 $this->translate( 'This plugin is also available in %1$s. <a href="%2$s">Help improve the translation!</a>', $primary_locale ), 145 wp_sprintf_l( '%l', $suggestions ), 134 146 esc_url( 'https://translate.wordpress.org/projects/wp-plugins/' . $plugin_slug ) 135 147 ); 136 148 } else { 137 149 $suggest_string = sprintf( 138 $this->translate( 'The plugin directory is also available in %s.', $locale ), 139 sprintf( 140 '<a href="https://%s.wordpress.org%s">%s</a>', 141 $locale_subdomain_assoc[ $locale ]->subdomain, 142 esc_url( $current_path ), 143 $language 144 ) 145 ); 146 } 147 148 // Multiple locale suggestions. 149 } elseif ( ! empty( $suggest_named_locales ) ) { 150 $primary_locale = key( $suggest_named_locales ); 151 $primary_language = current( $suggest_named_locales ); 152 array_shift( $suggest_named_locales ); 153 154 if ( $is_plugin_request ) { 155 $other_suggest = ''; 156 foreach ( $suggest_named_locales as $locale => $language ) { 157 $other_suggest .= sprintf( 158 '<a href="https://%s.wordpress.org%s/">%s</a>, ', 159 $locale_subdomain_assoc[ $locale ]->subdomain, 160 esc_url( $current_path ), 161 $language 162 ); 163 } 164 165 $suggest_string = sprintf( 166 $this->translate( 'This plugin is also available in %1$s (also: %2$s). <a href="%3$s">Help improve the translation!</a>', $primary_locale ), 167 sprintf( 168 '<a href="https://%s.wordpress.org%s">%s</a>', 169 $locale_subdomain_assoc[ $primary_locale ]->subdomain, 170 esc_url( $current_path ), 171 $primary_language 172 ), 173 trim( $other_suggest, ' ,' ), 174 esc_url( 'https://translate.wordpress.org/projects/wp-plugins/' . $plugin_slug ) 175 ); 176 } else { 177 $other_suggest = ''; 178 foreach ( $suggest_named_locales as $locale => $language ) { 179 $other_suggest .= sprintf( 180 '<a href="https://%s.wordpress.org%s">%s</a>, ', 181 $locale_subdomain_assoc[ $locale ]->subdomain, 182 esc_url( $current_path ), 183 $language 184 ); 185 } 186 187 $suggest_string = sprintf( 188 $this->translate( 'The plugin directory is also available in %1$s (also: %2$s).', $primary_locale ), 189 sprintf( 190 '<a href="https://%s.wordpress.org%s">%s</a>', 191 $locale_subdomain_assoc[ $primary_locale ]->subdomain, 192 esc_url( $current_path ), 193 $primary_language 194 ), 195 trim( $other_suggest, ' ,' ) 150 $this->translate( 'The plugin directory is also available in %s.', $primary_locale ), 151 wp_sprintf_l( '%l', $suggestions ), 196 152 ); 197 153 } … … 349 305 $strings = array( 350 306 5118332 => 'This plugin is also available in %1$s. <a href="%2$s">Help improve the translation!</a>', 351 5118333 => 'This plugin is also available in %1$s (also: %2$s). <a href="%3$s">Help improve the translation!</a>',352 307 2984795 => 'This plugin is not translated into %1$s yet. <a href="%2$s">Help translate it!</a>', 353 308 3004513 => 'The plugin directory is also available in %s.', 354 3004514 => 'The plugin directory is also available in %1$s (also: %2$s).', 309 310 // These are in wp/dev 311 7233895 => '%1$s, %2$s', 312 7234333 => '%1$s, and %2$s', 313 7960 => '%1$s and %2$s', 355 314 ); 356 315 … … 367 326 } 368 327 369 // Magic number: 348841 is meta/plugins-v3 .328 // Magic number: 348841 is meta/plugins-v3, 2 is wp/dev. 370 329 $translations = $wpdb->get_results( $wpdb->prepare( " 371 330 SELECT … … 375 334 ON ts.id = t.translation_set_id 376 335 WHERE 377 project_id = 348841AND slug = 'default' AND t.status = 'current'336 project_id IN ( 2, 348841 ) AND slug = 'default' AND t.status = 'current' 378 337 AND original_id = %d 379 338 ", $original_id ), OBJECT_K ); … … 391 350 392 351 // Strings for the POT file. 393 /* translators: %s: native language name . */352 /* translators: %s: native language name, possibly comma-separated list. */ 394 353 __( 'This plugin is also available in %1$s. <a href="%2$s">Help improve the translation!</a>', 'wporg-plugins' ); 395 /* translators: 1: native language name, 2: other native language names, comma separated */396 __( 'This plugin is also available in %1$s (also: %2$s). <a href="%3$s">Help improve the translation!</a>', 'wporg-plugins' );397 354 /* translators: 1: native language name, 2: URL to translate.wordpress.org */ 398 355 __( 'This plugin is not translated into %1$s yet. <a href="%2$s">Help translate it!</a>', 'wporg-plugins' ); 399 /* translators: %s: native language name . */356 /* translators: %s: native language name, possibly comma-separated list. */ 400 357 __( 'The plugin directory is also available in %s.', 'wporg-plugins' ); 401 /* translators: 1: native language name, 2: other native language names, comma separated */402 __( 'The plugin directory is also available in %1$s (also: %2$s).', 'wporg-plugins' );
Note: See TracChangeset
for help on using the changeset viewer.