Changeset 1163 for sites/trunk/wordpress.org/public_html/wp-content/plugins/wp-i18n-teams/wp-i18n-teams.php
- Timestamp:
- 01/22/2015 07:18:11 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/wp-i18n-teams/wp-i18n-teams.php
r1139 r1163 104 104 public function get_locales_data() { 105 105 global $wpdb; 106 107 $cache = get_transient( 'wp_i18n_teams_locales_data' ); 108 if ( false !== $cache ) { 109 return $cache; 110 } 111 106 112 $gp_locales = self::get_locales(); 113 $translation_data = $this->get_core_translation_data(); 107 114 $locale_data = array(); 108 115 109 $statuses = array( 'no-site' => 0, 'no-releases' => 0, 'latest' => 0, 'minor-behind' => 0, 'major-behind-one' => 0, 'major-behind-many' => 0 ); 116 $statuses = array( 117 'no-site' => 0, 118 'no-releases' => 0, 119 'latest' => 0, 120 'minor-behind' => 0, 121 'major-behind-one' => 0, 122 'major-behind-many' => 0, 123 'translated-100' => 0, 124 'translated-95' => 0, 125 'translated-90' => 0, 126 'translated-50' => 0, 127 'translated-50-less' => 0, 128 ); 110 129 111 130 $wporg_data = $wpdb->get_results( "SELECT locale, subdomain, latest_release FROM locales ORDER BY locale", OBJECT_K ); … … 114 133 $subdomain = $wporg_data[ $locale->wp_locale ]->subdomain; 115 134 $latest_release = $wporg_data[ $locale->wp_locale ]->latest_release; 116 $status = self::get_locale_status( $subdomain, $latest_release ); 117 $statuses[ $status ]++; 135 $release_status = self::get_locale_release_status( $subdomain, $latest_release ); 136 $statuses[ $release_status ]++; 137 138 $translation_status = ''; 139 if ( isset ( $translation_data[ $locale->wp_locale ] ) ) { 140 $translation_status = self::get_locale_translation_status( $translation_data[ $locale->wp_locale ] ); 141 $statuses[ $translation_status ]++; 142 } 118 143 119 144 $locale_data[ $locale->wp_locale ] = array( 120 'status' => $status, 121 'rosetta_site_url' => $subdomain ? 'https://' . $subdomain . '.wordpress.org' : false, 122 'latest_release' => $latest_release ? $latest_release : false, 145 'release_status' => $release_status, 146 'translation_status' => $translation_status, 147 'rosetta_site_url' => $subdomain ? 'https://' . $subdomain . '.wordpress.org' : false, 148 'latest_release' => $latest_release ? $latest_release : false, 123 149 ); 124 150 } 125 151 126 152 $locale_data['status_counts'] = $statuses; 127 $locale_data['status_counts']['all'] = array_sum( $statuses ); 153 $locale_data['status_counts']['all'] = count( $gp_locales ); 154 set_transient( 'wp_i18n_teams_locales_data', $locale_data, 900 ); 128 155 return $locale_data; 129 156 } … … 201 228 202 229 /** 203 * Determine the status of the given locale230 * Determine the release status of the given locale, 204 231 * 205 232 * @param string $rosetta_site_url … … 208 235 * @return string 209 236 */ 210 protected static function get_locale_ status( $rosetta_site_url, $latest_release ) {237 protected static function get_locale_release_status( $rosetta_site_url, $latest_release ) { 211 238 if ( ! $rosetta_site_url ) { 212 239 return 'no-site'; … … 229 256 } 230 257 } 258 259 /** 260 * Determine the translation status of the given locale. 261 * 262 * @param int $percent_translated 263 * 264 * @return string 265 */ 266 protected static function get_locale_translation_status( $percent_translated ) { 267 if ( $percent_translated == 100 ) { 268 return 'translated-100'; 269 } elseif ( $percent_translated >= 95 ) { 270 return 'translated-95'; 271 } elseif ( $percent_translated >= 90 ) { 272 return 'translated-90'; 273 } elseif ( $percent_translated >= 50 ) { 274 return 'translated-50'; 275 } else { 276 return 'translated-50-less'; 277 } 278 } 231 279 } 232 280
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)