Changeset 6029
- Timestamp:
- 10/14/2017 11:46:34 AM (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
r5983 r6029 73 73 $current_locale_is_translated = in_array( $current_locale, $translated_locales ); 74 74 75 require_once GLOTPRESS_LOCALES_PATH; 76 75 77 // Get the native language names of the locales. 76 78 $suggest_named_locales = []; 77 79 foreach ( $suggest_locales as $locale ) { 78 $name = $this->get_native_language_name( $locale ); 79 if ( $name ) { 80 $suggest_named_locales[ $locale ] = $name; 81 } 80 $suggest_named_locales[ $locale ] = \GP_Locales::by_field( 'wp_locale', $locale )->native_name; 82 81 } 83 82 … … 175 174 $suggest_string = sprintf( 176 175 $this->translate( 'This plugin is not available in %1$s yet. <a href="%2$s">Help translate it!</a>', $current_locale ), 177 $this->get_native_language_name( $current_locale ),176 \GP_Locales::by_field( 'wp_locale', $current_locale )->native_name, 178 177 esc_url( 'https://translate.wordpress.org/projects/wp-plugins/' . $plugin_slug ) 179 178 ); … … 313 312 } 314 313 315 require_once GLOTPRESS_LOCALES_PATH;316 314 $gp_locale = \GP_Locales::by_field( 'wp_locale', $wp_locale )->slug; 317 315 … … 342 340 return isset( $translations[ $gp_locale ] ) ? $translations[ $gp_locale ] : $string; 343 341 } 344 345 protected function get_native_language_name( $locale ) {346 global $wpdb;347 348 $slug = str_replace( '_', '-', $locale );349 $slug = strtolower( $slug );350 351 $name = $wpdb->get_var( $wpdb->prepare( 'SELECT name FROM languages WHERE slug = %s', $slug ) );352 if ( ! $name ) {353 $fallback_slug = explode( '-', $slug )[0]; // de-de => de354 $name = $wpdb->get_var( $wpdb->prepare( 'SELECT name FROM languages WHERE slug = %s', $fallback_slug ) );355 if ( $name ) {356 return $name;357 }358 } else {359 return $name;360 }361 362 return '';363 }364 342 } 365 343
Note: See TracChangeset
for help on using the changeset viewer.