<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[10628] sites/trunk/wordpress.org/public_html/wp-content/plugins/wp-i18n-teams: WP I18N Teams: Split main plugin class out into separate include files.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="http://meta.trac.wordpress.org/changeset/10628">10628</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"http://meta.trac.wordpress.org/changeset/10628","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>ocean90</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2021-01-24 14:30:29 +0000 (Sun, 24 Jan 2021)</dd>
</dl>

<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>WP I18N Teams: Split main plugin class out into separate include files.

See <a href="http://meta.trac.wordpress.org/ticket/3423">#3423</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentpluginswpi18nteamswpi18nteamsphp">sites/trunk/wordpress.org/public_html/wp-content/plugins/wp-i18n-teams/wp-i18n-teams.php</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li>sites/trunk/wordpress.org/public_html/wp-content/plugins/wp-i18n-teams/inc/</li>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentpluginswpi18nteamsinclocalesphp">sites/trunk/wordpress.org/public_html/wp-content/plugins/wp-i18n-teams/inc/locales.php</a></li>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentpluginswpi18nteamsincnamespacephp">sites/trunk/wordpress.org/public_html/wp-content/plugins/wp-i18n-teams/inc/namespace.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentpluginswpi18nteamsinclocalesphp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: sites/trunk/wordpress.org/public_html/wp-content/plugins/wp-i18n-teams/inc/locales.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordpress.org/public_html/wp-content/plugins/wp-i18n-teams/inc/locales.php                            (rev 0)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/wp-i18n-teams/inc/locales.php      2021-01-24 14:30:29 UTC (rev 10628)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,555 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+/**
+ * Shortcode for displaying details about translation teams.
+ */
+
+namespace WordPressdotorg\I18nTeams\Locales;
+
+use GP_Locale;
+use GP_Locales;
+use WP_User;
+use const WordPressdotorg\I18nTeams\PLUGIN_DIR;
+use const WordPressdotorg\I18nTeams\PLUGIN_FILE;
+use function WordPressdotorg\I18nTeams\get_locales;
+
+/**
+ * Inits the shortcode for displaying details about translation teams.
+ */
+function bootstrap(): void {
+       add_action( 'wp_enqueue_scripts', __NAMESPACE__ . '\enqueue_assets', 20 );
+       add_shortcode( 'wp-locales', __NAMESPACE__ . '\render_wp_locales_shortcode' );
+}
+
+/**
+ * Enqueues JavaScript and CSS.
+ */
+function enqueue_assets(): void {
+       if ( is_singular() && false !== strpos( get_post()->post_content, '[wp-locales' ) ) {
+               wp_enqueue_style( 'wp-i18n-teams', plugins_url( 'css/i18n-teams.css', PLUGIN_FILE ), [], 13 );
+               wp_enqueue_script( 'wp-i18n-teams', plugins_url( 'js/i18n-teams.js', PLUGIN_FILE ), [ 'jquery', 'o2-app' ], 5 );
+       }
+}
+
+/**
+ * Render the [wp-locales] shortcode.
+ */
+function render_wp_locales_shortcode(): string {
+       ob_start();
+
+       if ( empty( $_GET['locale'] ) ) {
+               $locales             = get_locales();
+               $locale_data         = get_locales_data();
+               $percentages         = get_core_translation_data();
+               $language_packs_data = get_language_packs_data();
+               include PLUGIN_DIR . '/views/all-locales.php';
+       } else {
+               require_once GLOTPRESS_LOCALES_PATH;
+               $locale = GP_Locales::by_field( 'wp_locale', $_GET['locale'] );
+               if ( $locale ) {
+                       $locale_data = get_extended_locale_data( $locale );
+                       include PLUGIN_DIR . '/views/locale-details.php';
+               } else {
+                       printf(
+                               '<div class="callout callout-warning"><p>%s</p><p><a href="%s">%s</a></p></div>',
+                               sprintf(
+                                       __( 'Locale %s doesn&#8217;t exist.', 'wporg' ),
+                                       '<code>' . esc_html( $_GET['locale'] ) . '</code>'
+                               ),
+                               esc_url( get_permalink() ),
+                               __( 'Return to All Locales', 'wporg' )
+                       );
+               }
+       }
+
+       return ob_get_clean();
+}
+
+/**
+ * Retrieves all the required data and caches it.
+ */
+function get_locales_data() {
+       global $wpdb;
+
+       $cache = get_transient( 'wp_i18n_teams_locales_data' );
+       if ( false !== $cache ) {
+               return $cache;
+       }
+
+       $gp_locales          = get_locales();
+       $translation_data    = get_core_translation_data();
+       $language_packs_data = get_language_packs_data();
+       $locale_data         = [];
+
+       $statuses = [
+               'no-wp-project'      => 0,
+               'no-site'            => 0,
+               'no-releases'        => 0,
+               'latest'             => 0,
+               'minor-behind'       => 0,
+               'major-behind-one'   => 0,
+               'major-behind-many'  => 0,
+               'translated-100'     => 0,
+               'translated-95'      => 0,
+               'translated-90'      => 0,
+               'translated-50'      => 0,
+               'translated-50-less' => 0,
+               'has-language-pack'  => 0,
+               'no-language-pack'   => 0,
+       ];
+
+       $wporg_data = $wpdb->get_results( 'SELECT locale, subdomain, latest_release FROM wporg_locales ORDER BY locale', OBJECT_K );
+
+       foreach ( $gp_locales as $locale ) {
+               $subdomain = $latest_release = '';
+               if ( ! empty( $wporg_data[ $locale->wp_locale ] ) ) {
+                       $subdomain      = $wporg_data[ $locale->wp_locale ]->subdomain;
+                       $latest_release = $wporg_data[ $locale->wp_locale ]->latest_release;
+               }
+               $release_status = get_locale_release_status( $subdomain, $latest_release );
+               $statuses[ $release_status ]++;
+
+               if ( isset( $translation_data[ $locale->wp_locale ] ) ) {
+                       $translation_status = get_locale_translation_status( $translation_data[ $locale->wp_locale ] );
+               } else {
+                       $translation_status = 'no-wp-project';
+               }
+               $statuses[ $translation_status ]++;
+
+               if ( isset( $language_packs_data[ $locale->wp_locale ] ) ) {
+                       $language_pack_status = 'has-language-pack';
+               } else {
+                       $language_pack_status = 'no-language-pack';
+               }
+               $statuses[ $language_pack_status ]++;
+
+               $sites = get_sites(
+                       [
+                               'locale'     => $locale->wp_locale,
+                               'network_id' => WPORG_GLOBAL_NETWORK_ID,
+                               'orderby'    => 'path_length',
+                               'number'     => '',
+                       ]
+               );
+
+               $locale_data[ $locale->wp_locale ] = [
+                       'release_status'       => $release_status,
+                       'translation_status'   => $translation_status,
+                       'language_pack_status' => $language_pack_status,
+                       'sites'                => $sites,
+                       'subdomain'            => $subdomain,
+                       'rosetta_site_url'     => "https://$subdomain.wordpress.org/",
+                       'latest_release'       => $latest_release ? $latest_release : false,
+               ];
+       }
+
+       $locale_data['status_counts']        = $statuses;
+       $locale_data['status_counts']['all'] = \count( $gp_locales );
+       set_transient( 'wp_i18n_teams_locales_data', $locale_data, 900 );
+       return $locale_data;
+}
+
+/**
+ * Retrieves all the language packs data and caches it.
+ */
+function get_language_packs_data() {
+       global $wpdb;
+
+       $cache = get_transient( 'wp_i18n_teams_language_packs_data' );
+       if ( false !== $cache ) {
+               return $cache;
+       }
+
+       $language_packs = $wpdb->get_results( "SELECT language AS locale, version FROM `language_packs` WHERE `type` = 'core' AND `active` = 1 AND `version` NOT LIKE '%-%'" );
+
+       $language_packs_data = [];
+       foreach ( $language_packs as $pack ) {
+               if ( ! isset( $language_packs_data[ $pack->locale ] ) ) {
+                       $language_packs_data[ $pack->locale ] = [];
+               }
+
+               $language_packs_data[ $pack->locale ][] = $pack->version;
+       }
+
+       set_transient( 'wp_i18n_teams_language_packs_data', $language_packs_data, 900 );
+
+       return $language_packs_data;
+}
+
+/**
+ * Retrieves all the required data.
+ */
+function get_extended_locale_data( $locale ) {
+       $locales_data = get_locales_data();
+
+       $locale_data = $locales_data[ $locale->wp_locale ];
+
+       $locale_data['localized_core_url'] = false;
+       $locale_data['language_pack_url']  = false;
+
+       $latest_release = $locale_data['latest_release'];
+       if ( $latest_release ) {
+               $locale_data['localized_core_url'] = sprintf( 'https://downloads.wordpress.org/release/%s/wordpress-%s.zip', $locale->wp_locale, $latest_release );
+               $language_packs_data               = get_language_packs_data();
+
+               if ( version_compare( $latest_release, '4.0', '>=' ) && ! empty( $language_packs_data[ $locale->wp_locale ] ) ) {
+                       list( $x, $y ) = explode( '.', $latest_release );
+                       $latest_branch = "$x.$y";
+
+                       $pack_version = null;
+                       if ( \in_array( $latest_release, $language_packs_data[ $locale->wp_locale ] ) ) {
+                               $pack_version = $latest_release;
+                       } elseif ( \in_array( $latest_branch, $language_packs_data[ $locale->wp_locale ] ) ) {
+                               $pack_version = $latest_branch;
+                       }
+
+                       if ( $pack_version ) {
+                               $locale_data['language_pack_version'] = $pack_version;
+                               $locale_data['language_pack_url']     = sprintf( 'https://downloads.wordpress.org/translation/core/%s/%s.zip', $pack_version, $locale->wp_locale );
+                       }
+               }
+       }
+
+       $contributors                      = get_contributors( $locale );
+       $locale_data['locale_managers']    = $contributors['locale_managers'];
+       $locale_data['validators']         = $contributors['validators'];
+       $locale_data['project_validators'] = $contributors['project_validators'];
+       $locale_data['translators']        = $contributors['translators'];
+       $locale_data['translators_past']   = $contributors['translators_past'];
+
+       return $locale_data;
+}
+
+/**
+ * Retrieves the translators and validators for the given locale.
+ *
+ * @return array
+ */
+function get_contributors( GP_Locale $locale ): array {
+       $cache = wp_cache_get( 'contributors-data:' . $locale->wp_locale, 'wp-i18n-teams' );
+       if ( false !== $cache ) {
+               return $cache;
+       }
+
+       // Editors are only assigned to the parent locale.
+       $parent_locale = null;
+       if ( isset( $locale->root_slug ) ) {
+               $parent_locale = GP_Locales::by_slug( $locale->root_slug );
+       }
+
+       $contributors                       = [];
+       $contributors['locale_managers']    = get_locale_managers( $parent_locale ?? $locale );
+       $contributors['validators']         = get_general_translation_editors( $parent_locale ?? $locale );
+       $contributors['project_validators'] = get_project_translation_editors( $parent_locale ?? $locale );
+       $contributors['translators']        = get_translation_contributors( $locale, 365 ); // Contributors from the past year
+       $contributors['translators_past']   = array_diff_key( get_translation_contributors( $locale ), $contributors['translators'] );
+
+       wp_cache_set( 'contributors-data:' . $locale->wp_locale, $contributors, 'wp-i18n-teams', 2 * HOUR_IN_SECONDS );
+
+       return $contributors;
+}
+
+/**
+ * Retrieves the core translations data and caches it.
+ *
+ * @return array
+ */
+function get_core_translation_data() {
+       $cache = get_transient( 'core_translation_data' );
+       if ( false !== $cache ) {
+               return $cache;
+       }
+
+       $projects = [ 'wp/dev', 'wp/dev/cc', 'wp/dev/admin', 'wp/dev/admin/network' ];
+       $counts   = $percentages = [];
+       foreach ( $projects as $project ) {
+               $results = json_decode( file_get_contents( 'https://translate.wordpress.org/api/projects/' . $project ) );
+               foreach ( $results->translation_sets as $set ) {
+
+                       if ( ! isset( $set->wp_locale ) ) {
+                               continue;
+                       }
+
+                       $wp_locale = $set->wp_locale;
+                       if ( 'default' !== $set->slug ) {
+                               $wp_locale = $wp_locale . '_' . $set->slug;
+                       }
+
+                       if ( ! isset( $counts[ $wp_locale ] ) ) {
+                               $counts[ $wp_locale ] = 0;
+                       }
+                       $counts[ $wp_locale ] += (int) $set->percent_translated;
+               }
+       }
+
+       foreach ( $counts as $locale => $percent_translated ) {
+               // English locales don't have wp/dev/cc.
+               $projects_count = 0 === strpos( $locale, 'en_' ) ? 3 : 4;
+
+               /*
+                * > 50% round down, so that a project with all strings except 1 translated shows 99%, instead of 100%.
+                * < 50% round up, so that a project with just a few strings shows 1%, instead of 0%.
+                */
+               $percent_complete = 100 / ( 100 * $projects_count ) * $percent_translated;
+               $percent_complete = ( $percent_complete > 50 ) ? floor( $percent_complete ) : ceil( $percent_complete );
+
+               $percentages[ $locale ] = $percent_complete;
+       }
+
+       set_transient( 'core_translation_data', $percentages, 900 );
+
+       return $percentages;
+}
+
+/**
+ * Get the locale managers for the given locale.
+ *
+ * @return array
+ */
+function get_locale_managers( GP_Locale $locale ): array {
+       $locale_managers = [];
+
+       $result  = get_sites(
+               [
+                       'locale'     => $locale->wp_locale,
+                       'network_id' => WPORG_GLOBAL_NETWORK_ID,
+                       'path'       => '/',
+                       'fields'     => 'ids',
+                       'number'     => '1',
+               ]
+       );
+       $site_id = array_shift( $result );
+       if ( ! $site_id ) {
+               return $locale_managers;
+       }
+
+       $users = get_users(
+               [
+                       'blog_id'     => $site_id,
+                       'role'        => 'locale_manager',
+                       'count_total' => false,
+               ]
+       );
+
+       foreach ( $users as $user ) {
+               $locale_managers[ $user->user_nicename ] = prepare_user( $user );
+       }
+
+       uasort( $locale_managers, fn( $a, $b ) => strnatcasecmp( $a['display_name'], $b['display_name'] ) );
+
+       return $locale_managers;
+}
+
+/**
+ * Get the general translation editors for the given locale.
+ *
+ * @return array
+ */
+function get_general_translation_editors( GP_Locale $locale ): array {
+       $editors = [];
+
+       $result  = get_sites(
+               [
+                       'locale'     => $locale->wp_locale,
+                       'network_id' => WPORG_GLOBAL_NETWORK_ID,
+                       'path'       => '/',
+                       'fields'     => 'ids',
+                       'number'     => '1',
+               ]
+       );
+       $site_id = array_shift( $result );
+       if ( ! $site_id ) {
+               return $editors;
+       }
+
+       $users = get_users(
+               [
+                       'blog_id'     => $site_id,
+                       'role'        => 'general_translation_editor',
+                       'count_total' => false,
+               ]
+       );
+
+       foreach ( $users as $user ) {
+               $editors[ $user->user_nicename ] = prepare_user( $user );
+       }
+
+       uasort( $editors, fn( $a, $b ) => strnatcasecmp( $a['display_name'], $b['display_name'] ) );
+
+       return $editors;
+}
+
+/**
+ * Get the general translation editors for the given locale.
+ *
+ * @return array
+ */
+function get_project_translation_editors( GP_Locale $locale ): array {
+       $editors = [];
+
+       $result  = get_sites(
+               [
+                       'locale'     => $locale->wp_locale,
+                       'network_id' => WPORG_GLOBAL_NETWORK_ID,
+                       'path'       => '/',
+                       'fields'     => 'ids',
+                       'number'     => '1',
+               ]
+       );
+       $site_id = array_shift( $result );
+       if ( ! $site_id ) {
+               return $editors;
+       }
+
+       $users = get_users(
+               [
+                       'blog_id'     => $site_id,
+                       'role'        => 'translation_editor',
+                       'count_total' => false,
+               ]
+       );
+
+       foreach ( $users as $user ) {
+               $editors[ $user->user_nicename ] = prepare_user( $user );
+       }
+
+       uasort( $editors, fn( $a, $b ) => strnatcasecmp( $a['display_name'], $b['display_name'] ) );
+
+       return $editors;
+}
+
+/**
+ * Prepares user objects for output.
+ *
+ * @param \WP_User $user The user.
+ * @return array List of user data.
+ */
+function prepare_user( WP_User $user ): array {
+       if ( $user->display_name && $user->display_name !== $user->user_nicename ) {
+               return [
+                       'display_name' => $user->display_name,
+                       'email'        => $user->user_email,
+                       'nice_name'    => $user->user_nicename,
+                       'slack'        => get_slack_username( $user->ID ),
+               ];
+       } else {
+               return [
+                       'display_name' => $user->user_nicename,
+                       'email'        => $user->user_email,
+                       'nice_name'    => $user->user_nicename,
+                       'slack'        => get_slack_username( $user->ID ),
+               ];
+       }
+}
+
+/**
+ * Gets the translation contributors for the given locale.
+ *
+ * @return array
+ */
+function get_translation_contributors( GP_Locale $locale, $max_age_days = null ): array {
+       global $wpdb;
+
+       $contributors = [];
+
+       $date_constraint = '';
+       if ( null !== $max_age_days ) {
+               $date_constraint = $wpdb->prepare( ' AND date_modified >= CURRENT_DATE - INTERVAL %d DAY', $max_age_days );
+       }
+
+       [ $locale, $locale_slug ] = array_merge( explode( '/', $locale->slug ), [ 'default' ] );
+
+       $users = $wpdb->get_col(
+               $wpdb->prepare(
+                       'SELECT DISTINCT user_id FROM translate_user_translations_count WHERE accepted > 0 AND locale = %s AND locale_slug = %s',
+                       $locale,
+                       $locale_slug
+               ) . $date_constraint
+       );
+
+       if ( ! $users ) {
+               return $contributors;
+       }
+
+       $user_data = $wpdb->get_results( "SELECT user_nicename, display_name, user_email FROM $wpdb->users WHERE ID IN (" . implode( ',', $users ) . ')' );
+       foreach ( $user_data as $user ) {
+               if ( $user->display_name && $user->display_name !== $user->user_nicename ) {
+                       $contributors[ $user->user_nicename ] = [
+                               'display_name' => $user->display_name,
+                               'nice_name'    => $user->user_nicename,
+                       ];
+               } else {
+                       $contributors[ $user->user_nicename ] = [
+                               'display_name' => $user->user_nicename,
+                               'nice_name'    => $user->user_nicename,
+                       ];
+               }
+       }
+
+       uasort( $contributors, fn( $a, $b ) => strnatcasecmp( $a['display_name'], $b['display_name'] ) );
+
+       return $contributors;
+}
+
+/**
+ * Determines the release status of the given locale,
+ */
+function get_locale_release_status( string $rosetta_site_url, string $latest_release ): string {
+       if ( ! $rosetta_site_url ) {
+               return 'no-site';
+       }
+
+       if ( ! $latest_release ) {
+               return 'no-releases';
+       }
+
+       $one_lower = \floatval( WP_CORE_LATEST_RELEASE ) - 0.1;
+
+       if ( $latest_release == WP_CORE_LATEST_RELEASE ) {
+               return 'latest';
+       } elseif ( substr( $latest_release, 0, 3 ) == substr( WP_CORE_LATEST_RELEASE, 0, 3 ) ) {
+               return 'minor-behind';
+       } elseif ( substr( $latest_release, 0, 3 ) == substr( $one_lower, 0, 3 ) ) {
+               return 'major-behind-one';
+       } else {
+               return 'major-behind-many';
+       }
+}
+
+/**
+ * Determines the translation status of the given locale.
+ */
+function get_locale_translation_status( int $percent_translated ): string {
+       if ( $percent_translated == 100 ) {
+               return 'translated-100';
+       } elseif ( $percent_translated >= 95 ) {
+               return 'translated-95';
+       } elseif ( $percent_translated >= 90 ) {
+               return 'translated-90';
+       } elseif ( $percent_translated >= 50 ) {
+               return 'translated-50';
+       } else {
+               return 'translated-50-less';
+       }
+}
+
+/**
+ * Gets the Slack username for a .org user.
+ */
+function get_slack_username( int $user_id ): string {
+       global $wpdb;
+
+       $slack_username = '';
+
+       $data = $wpdb->get_var( $wpdb->prepare( 'SELECT profiledata FROM slack_users WHERE user_id = %d', $user_id ) );
+       if ( $data && ( $data = json_decode( $data, true ) ) ) {
+               if ( ! empty( $data['profile']['display_name'] ) && empty( $data['deleted'] ) ) {
+                       // Optional Display Name field.
+                       $slack_username = $data['profile']['display_name'];
+               } elseif ( ! empty( $data['profile']['real_name'] ) && empty( $data['deleted'] ) ) {
+                       // Fall back to "Full Name" field.
+                       $slack_username = $data['profile']['real_name'];
+               }
+       }
+
+       return $slack_username;
+}
</ins></span></pre></div>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentpluginswpi18nteamsincnamespacephp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: sites/trunk/wordpress.org/public_html/wp-content/plugins/wp-i18n-teams/inc/namespace.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordpress.org/public_html/wp-content/plugins/wp-i18n-teams/inc/namespace.php                          (rev 0)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/wp-i18n-teams/inc/namespace.php    2021-01-24 14:30:29 UTC (rev 10628)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,62 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+/**
+ * Namespaced functions.
+ */
+
+namespace WordPressdotorg\I18nTeams;
+
+use GP_Locales;
+
+/**
+ * Inits the plugin.
+ */
+function bootstrap() {
+       add_filter( 'term_link', __NAMESPACE__ . '\link_locales', 10, 3 );
+
+       Locales\bootstrap();
+}
+
+/**
+ * Links #locale to the teams page.
+ *
+ * @param string $termlink Term link URL.
+ * @param object $term     Term object.
+ * @param string $taxonomy Taxonomy slug.
+ * @return string URL to teams page of a locale.
+ */
+function link_locales( $termlink, $term, $taxonomy ) {
+       if ( 'post_tag' !== $taxonomy ) {
+               return $termlink;
+       }
+
+       static $available_locales;
+
+       if ( ! isset( $available_locales ) ) {
+               $available_locales = get_locales();
+               $available_locales = wp_list_pluck( $available_locales, 'wp_locale' );
+               $available_locales = array_flip( $available_locales );
+       }
+
+       if ( isset( $available_locales[ $term->name ] ) || isset( $available_locales[ $term->slug ] ) ) {
+               return sprintf( 'https://make.wordpress.org/polyglots/teams/?locale=%s', $term->name );
+       }
+
+       return $termlink;
+}
+
+
+/**
+ * Retrieves GlotPress locales that have a wp_locale, sorted alphabetically.
+ *
+ * @return array
+ */
+function get_locales() {
+       require_once GLOTPRESS_LOCALES_PATH;
+
+       $locales = GP_Locales::locales();
+       $locales = array_filter( $locales, fn( $locale ) => isset( $locale->wp_locale ) );
+       unset( $locales['en'] );
+       usort( $locales, fn( $a, $b ) => strcmp( $a->english_name, $b->english_name ) );
+
+       return $locales;
+}
</ins></span></pre></div>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentpluginswpi18nteamswpi18nteamsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordpress.org/public_html/wp-content/plugins/wp-i18n-teams/wp-i18n-teams.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordpress.org/public_html/wp-content/plugins/wp-i18n-teams/wp-i18n-teams.php  2021-01-22 23:00:57 UTC (rev 10627)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/wp-i18n-teams/wp-i18n-teams.php    2021-01-24 14:30:29 UTC (rev 10628)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,7 +1,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px"> /*
</span><span class="cx" style="display: block; padding: 0 10px"> Plugin Name: WP I18N Teams
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-Description: Provides shortcodes for displaying details about translation teams.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+Description: Provides shortcodes and blocks for managing translation teams.
</ins><span class="cx" style="display: block; padding: 0 10px"> Version:     1.0
</span><span class="cx" style="display: block; padding: 0 10px"> License:     GPLv2 or later
</span><span class="cx" style="display: block; padding: 0 10px"> Author:      WordPress.org
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -9,620 +9,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> Text Domain: wporg
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-class WP_I18n_Teams {
-       const TEAM_PAGE = 'https://make.wordpress.org/polyglots/teams/?locale=%s';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+namespace WordPressdotorg\I18nTeams;
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        public function __construct() {
-               add_action( 'plugins_loaded', array( $this, 'plugins_loaded' ) );
-       }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+const PLUGIN_FILE = __FILE__;
+const PLUGIN_DIR  = __DIR__;
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        /**
-        * Attaches hooks and registers shortcodes once plugins are loasded.
-        */
-       public function plugins_loaded() {
-               add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_assets' ), 20 );
-               add_shortcode( 'wp-locales',      array( $this, 'wp_locales' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+require_once PLUGIN_DIR . '/inc/namespace.php';
+require_once PLUGIN_DIR . '/inc/locales.php';
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                add_filter( 'term_link', array( $this, 'link_locales' ), 10, 3 );
-       }
-
-       /**
-        * Links #locale to the teams page.
-        *
-        * @param string $termlink Term link URL.
-        * @param object $term     Term object.
-        * @param string $taxonomy Taxonomy slug.
-        * @return string URL to teams page of a locale.
-        */
-       public function link_locales( $termlink, $term, $taxonomy ) {
-               if ( 'post_tag' !== $taxonomy ) {
-                       return $termlink;
-               }
-
-               static $available_locales;
-
-               if ( ! isset( $available_locales ) ) {
-                       $available_locales = self::get_locales();
-                       $available_locales = wp_list_pluck( $available_locales, 'wp_locale' );
-                       $available_locales = array_flip( $available_locales );
-               }
-
-               if ( isset( $available_locales[ $term->name ] ) || isset( $available_locales[ $term->slug ] ) ) {
-                       return sprintf( self::TEAM_PAGE, $term->name );
-               }
-
-               return $termlink;
-       }
-
-       /**
-        * Enqueue JavaScript and CSS
-        */
-       public function enqueue_assets() {
-               if ( is_singular() && false !== strpos( get_post()->post_content, '[wp-locales' ) ) {
-                       wp_enqueue_style( 'wp-i18n-teams', plugins_url( 'css/i18n-teams.css', __FILE__ ), array(), 13 );
-                       wp_enqueue_script( 'wp-i18n-teams', plugins_url( 'js/i18n-teams.js', __FILE__ ), array( 'jquery', 'o2-app' ), 5 );
-               }
-       }
-
-       /**
-        * Render the [wp-locales] shortcode.
-        *
-        * @param array $attributes
-        *
-        * @return string
-        */
-       public function wp_locales( $attributes ) {
-               ob_start();
-
-               if ( empty( $_GET['locale'] ) ) {
-                       $locales = self::get_locales();
-                       $locale_data = $this->get_locales_data();
-                       $percentages = $this->get_core_translation_data();
-                       $language_packs_data = $this->get_language_packs_data();
-                       require( __DIR__ . '/views/all-locales.php' );
-               } else {
-                       require_once GLOTPRESS_LOCALES_PATH;
-                       $locale = GP_Locales::by_field( 'wp_locale', $_GET['locale'] );
-                       if ( $locale ) {
-                               $locale_data = $this->get_extended_locale_data( $locale );
-                               require( __DIR__ . '/views/locale-details.php' );
-                       } else {
-                               printf(
-                                       '<div class="callout callout-warning"><p>%s</p><p><a href="%s">%s</a></p></div>',
-                                       sprintf(
-                                               __( 'Locale %s doesn&#8217;t exist.', 'wporg' ),
-                                               '<code>' . esc_html( $_GET['locale'] ) . '</code>'
-                                       ),
-                                       esc_url( get_permalink() ),
-                                       __( 'Return to All Locales', 'wporg' )
-                               );
-                       }
-               }
-
-               return ob_get_clean();
-       }
-
-       /**
-        * Get GlotPress locales that have a wp_locale, sorted alphabetically.
-        *
-        * @return array
-        */
-       protected static function get_locales() {
-               require_once GLOTPRESS_LOCALES_PATH;
-
-               $locales = GP_Locales::locales();
-               $locales = array_filter( $locales, array( __CLASS__, 'filter_locale_for_wp' ) );
-               unset( $locales['en'] );
-               usort( $locales, array( __CLASS__, 'sort_locales' ) );
-
-               return $locales;
-       }
-
-       /**
-        * Remove locales that are missing a wp_locale.
-        *
-        * This is a callback for array_filter().
-        *
-        * @param GP_Locale $element
-        *
-        * @return bool
-        */
-       protected static function filter_locale_for_wp( $element ) {
-               return isset( $element->wp_locale );
-       }
-
-       /**
-        * Sort GlotPress locales alphabetically by the English name.
-        *
-        * @param GP_Locale $a
-        * @param GP_Locale $b
-        *
-        * @return int
-        */
-       protected static function sort_locales( $a, $b ) {
-               return strcmp( $a->english_name, $b->english_name );
-       }
-
-       /**
-        * Gather all the required data and cache it.
-        */
-       public function get_locales_data() {
-               global $wpdb;
-
-               $cache = get_transient( 'wp_i18n_teams_locales_data' );
-               if ( false !== $cache ) {
-                       return $cache;
-               }
-
-               $gp_locales = self::get_locales();
-               $translation_data = $this->get_core_translation_data();
-               $language_packs_data = $this->get_language_packs_data();
-               $locale_data = array();
-
-               $statuses = array(
-                       'no-wp-project'      => 0,
-                       'no-site'            => 0,
-                       'no-releases'        => 0,
-                       'latest'             => 0,
-                       'minor-behind'       => 0,
-                       'major-behind-one'   => 0,
-                       'major-behind-many'  => 0,
-                       'translated-100'     => 0,
-                       'translated-95'      => 0,
-                       'translated-90'      => 0,
-                       'translated-50'      => 0,
-                       'translated-50-less' => 0,
-                       'has-language-pack'  => 0,
-                       'no-language-pack'   => 0,
-               );
-
-               $wporg_data = $wpdb->get_results( 'SELECT locale, subdomain, latest_release FROM wporg_locales ORDER BY locale', OBJECT_K );
-
-               foreach ( $gp_locales as $locale ) {
-                       $subdomain = $latest_release = '';
-                       if ( ! empty( $wporg_data[ $locale->wp_locale ] ) ) {
-                               $subdomain = $wporg_data[ $locale->wp_locale ]->subdomain;
-                               $latest_release = $wporg_data[ $locale->wp_locale ]->latest_release;
-                       }
-                       $release_status = self::get_locale_release_status( $subdomain, $latest_release );
-                       $statuses[ $release_status ]++;
-
-                       if ( isset( $translation_data[ $locale->wp_locale ] ) ) {
-                               $translation_status = self::get_locale_translation_status( $translation_data[ $locale->wp_locale ] );
-                       } else {
-                               $translation_status = 'no-wp-project';
-                       }
-                       $statuses[ $translation_status ]++;
-
-                       if ( isset( $language_packs_data[ $locale->wp_locale ] ) ) {
-                               $language_pack_status = 'has-language-pack';
-                       } else {
-                               $language_pack_status = 'no-language-pack';
-                       }
-                       $statuses[ $language_pack_status ]++;
-
-                       $sites = get_sites( [
-                               'locale'     => $locale->wp_locale,
-                               'network_id' => WPORG_GLOBAL_NETWORK_ID,
-                               'orderby'    => 'path_length',
-                               'number'     => '',
-                       ] );
-
-                       $locale_data[ $locale->wp_locale ] = array(
-                               'release_status'       => $release_status,
-                               'translation_status'   => $translation_status,
-                               'language_pack_status' => $language_pack_status,
-                               'sites'                => $sites,
-                               'subdomain'            => $subdomain,
-                               'rosetta_site_url'     => "https://$subdomain.wordpress.org/",
-                               'latest_release'       => $latest_release ? $latest_release : false,
-                       );
-               }
-
-               $locale_data['status_counts'] = $statuses;
-               $locale_data['status_counts']['all'] = count( $gp_locales );
-               set_transient( 'wp_i18n_teams_locales_data', $locale_data, 900 );
-               return $locale_data;
-       }
-
-       public function get_language_packs_data() {
-               global $wpdb;
-
-               $cache = get_transient( 'wp_i18n_teams_language_packs_data' );
-               if ( false !== $cache ) {
-                       return $cache;
-               }
-
-               $language_packs = $wpdb->get_results( "SELECT language AS locale, version FROM `language_packs` WHERE `type` = 'core' AND `active` = 1 AND `version` NOT LIKE '%-%'" );
-
-               $language_packs_data = array();
-               foreach ( $language_packs as $pack ) {
-                       if ( ! isset( $language_packs_data[ $pack->locale ] ) ) {
-                               $language_packs_data[ $pack->locale ] = array();
-                       }
-
-                       $language_packs_data[ $pack->locale ][] = $pack->version;
-               }
-
-               set_transient( 'wp_i18n_teams_language_packs_data', $language_packs_data, 900 );
-               return $language_packs_data;
-       }
-
-       public function get_extended_locale_data( $locale ) {
-               $locales_data = $this->get_locales_data();
-               $locale_data = $locales_data[ $locale->wp_locale ];
-               $locale_data['localized_core_url'] = $locale_data['language_pack_url'] = false;
-
-               $latest_release = $locale_data['latest_release'];
-               if ( $latest_release ) {
-                       $locale_data['localized_core_url'] = sprintf( 'https://downloads.wordpress.org/release/%s/wordpress-%s.zip', $locale->wp_locale, $latest_release );
-                       $language_packs_data = $this->get_language_packs_data();
-
-                       if ( version_compare( $latest_release, '4.0', '>=' ) && ! empty( $language_packs_data[ $locale->wp_locale ] ) ) {
-                               list( $x, $y ) = explode( '.', $latest_release );
-                               $latest_branch = "$x.$y";
-
-                               $pack_version = null;
-                               if ( in_array( $latest_release, $language_packs_data[ $locale->wp_locale ] ) ) {
-                                       $pack_version = $latest_release;
-                               } elseif ( in_array( $latest_branch, $language_packs_data[ $locale->wp_locale ] ) ) {
-                                       $pack_version = $latest_branch;
-                               }
-
-                               if ( $pack_version ) {
-                                       $locale_data['language_pack_version'] = $pack_version;
-                                       $locale_data['language_pack_url'] = sprintf( 'https://downloads.wordpress.org/translation/core/%s/%s.zip', $pack_version, $locale->wp_locale );
-                               }
-                       }
-               }
-
-               $contributors = $this->get_contributors( $locale );
-               $locale_data['locale_managers'] = $contributors['locale_managers'];
-               $locale_data['validators'] = $contributors['validators'];
-               $locale_data['project_validators'] = $contributors['project_validators'];
-               $locale_data['translators'] = $contributors['translators'];
-               $locale_data['translators_past'] = $contributors['translators_past'];
-
-               return $locale_data;
-       }
-
-       /**
-        * Get the translators and validators for the given locale.
-        *
-        * @param GP_Locale $locale
-        * @return array
-        */
-       public function get_contributors( $locale ) {
-               $cache = wp_cache_get( 'contributors-data:' . $locale->wp_locale, 'wp-i18n-teams' );
-               if ( false !== $cache ) {
-                       return $cache;
-               }
-
-               // Editors are only assigned to the parent locale.
-               $parent_locale = null;
-               if ( isset( $locale->root_slug ) ) {
-                       $parent_locale = GP_Locales::by_slug( $locale->root_slug );
-               }
-
-               $contributors = [];
-               $contributors['locale_managers'] = $this->get_locale_managers( $parent_locale ?? $locale );
-               $contributors['validators'] = $this->get_general_translation_editors( $parent_locale ?? $locale );
-               $contributors['project_validators'] = $this->get_project_translation_editors( $parent_locale ?? $locale );
-               $contributors['translators'] = $this->get_translation_contributors( $locale, 365 ); // Contributors from the past year
-               $contributors['translators_past'] = array_diff_key( $this->get_translation_contributors( $locale ), $contributors['translators'] );
-
-               wp_cache_set( 'contributors-data:' . $locale->wp_locale, $contributors, 'wp-i18n-teams', 2 * HOUR_IN_SECONDS );
-
-               return $contributors;
-       }
-
-       public function get_core_translation_data() {
-               $cache = get_transient( 'core_translation_data' );
-               if ( false !== $cache ) {
-                       return $cache;
-               }
-
-               $projects = array( 'wp/dev', 'wp/dev/cc', 'wp/dev/admin', 'wp/dev/admin/network' );
-               $counts = $percentages = array();
-               foreach ( $projects as $project ) {
-                       $results = json_decode( file_get_contents( 'https://translate.wordpress.org/api/projects/' . $project ) );
-                       foreach ( $results->translation_sets as $set ) {
-
-                               if ( ! isset( $set->wp_locale ) ) {
-                                       continue;
-                               }
-
-                               $wp_locale = $set->wp_locale;
-                               if ( $set->slug !== 'default' ) {
-                                       $wp_locale = $wp_locale . '_' . $set->slug;
-                               }
-
-                               if ( ! isset( $counts[ $wp_locale ] ) ) {
-                                       $counts[ $wp_locale ] = 0;
-                               }
-                               $counts[ $wp_locale ] += (int) $set->percent_translated;
-                       }
-               }
-
-               foreach ( $counts as $locale => $percent_translated ) {
-                       // English locales don't have wp/dev/cc.
-                       $projects_count = 0 === strpos( $locale, 'en_' ) ? 3 : 4;
-
-                       /*
-                        * > 50% round down, so that a project with all strings except 1 translated shows 99%, instead of 100%.
-                        * < 50% round up, so that a project with just a few strings shows 1%, instead of 0%.
-                        */
-                       $percent_complete = 100 / ( 100 * $projects_count ) * $percent_translated;
-                       $percent_complete = ( $percent_complete > 50 ) ? floor( $percent_complete ) : ceil( $percent_complete );
-
-                       $percentages[ $locale ] = $percent_complete;
-               }
-
-               set_transient( 'core_translation_data', $percentages, 900 );
-
-               return $percentages;
-       }
-
-       /**
-        * Get the locale managers for the given locale.
-        *
-        * @param GP_Locale $locale
-        * @return array
-        */
-       private function get_locale_managers( $locale ) {
-               $locale_managers = [];
-
-               $result = get_sites( [
-                       'locale'     => $locale->wp_locale,
-                       'network_id' => WPORG_GLOBAL_NETWORK_ID,
-                       'path'       => '/',
-                       'fields'     => 'ids',
-                       'number'     => '1',
-               ] );
-               $site_id = array_shift( $result );
-               if ( ! $site_id ) {
-                       return $locale_managers;
-               }
-
-               $users = get_users( [
-                       'blog_id'     => $site_id,
-                       'role'        => 'locale_manager',
-                       'count_total' => false,
-               ] );
-
-               foreach ( $users as $user ) {
-                       $locale_managers[ $user->user_nicename ] = $this->prepare_user( $user );
-               }
-
-               uasort( $locale_managers, [ $this, '_sort_display_name_callback' ] );
-
-               return $locale_managers;
-       }
-
-       /**
-        * Get the general translation editors for the given locale.
-        *
-        * @param GP_Locale $locale
-        * @return array
-        */
-       private function get_general_translation_editors( $locale ) {
-               $editors = [];
-
-               $result = get_sites( [
-                       'locale'     => $locale->wp_locale,
-                       'network_id' => WPORG_GLOBAL_NETWORK_ID,
-                       'path'       => '/',
-                       'fields'     => 'ids',
-                       'number'     => '1',
-               ] );
-               $site_id = array_shift( $result );
-               if ( ! $site_id ) {
-                       return $editors;
-               }
-
-               $users = get_users( [
-                       'blog_id'     => $site_id,
-                       'role'        => 'general_translation_editor',
-                       'count_total' => false,
-               ] );
-
-               foreach ( $users as $user ) {
-                       $editors[ $user->user_nicename ] = $this->prepare_user( $user );
-               }
-
-               uasort( $editors, [ $this, '_sort_display_name_callback' ] );
-
-               return $editors;
-       }
-
-       /**
-        * Get the general translation editors for the given locale.
-        *
-        * @param GP_Locale $locale
-        * @return array
-        */
-       private function get_project_translation_editors( $locale ) {
-               $editors = [];
-
-               $result = get_sites( [
-                       'locale'     => $locale->wp_locale,
-                       'network_id' => WPORG_GLOBAL_NETWORK_ID,
-                       'path'       => '/',
-                       'fields'     => 'ids',
-                       'number'     => '1',
-               ] );
-               $site_id = array_shift( $result );
-               if ( ! $site_id ) {
-                       return $editors;
-               }
-
-               $users = get_users( [
-                       'blog_id'     => $site_id,
-                       'role'        => 'translation_editor',
-                       'count_total' => false,
-               ] );
-
-               foreach ( $users as $user ) {
-                       $editors[ $user->user_nicename ] = $this->prepare_user( $user );
-               }
-
-               uasort( $editors, [ $this, '_sort_display_name_callback' ] );
-
-               return $editors;
-       }
-
-       /**
-        * Prepares user objects for output.
-        *
-        * @param \WP_User $user The user.
-        * @return array List of user data.
-        */
-       private function prepare_user( $user ) {
-               if ( $user->display_name && $user->display_name !== $user->user_nicename ) {
-                       return [
-                               'display_name' => $user->display_name,
-                               'email'        => $user->user_email,
-                               'nice_name'    => $user->user_nicename,
-                               'slack'        => self::get_slack_username( $user->ID ),
-                       ];
-               } else {
-                       return [
-                               'display_name' => $user->user_nicename,
-                               'email'        => $user->user_email,
-                               'nice_name'    => $user->user_nicename,
-                               'slack'        => self::get_slack_username( $user->ID ),
-                       ];
-               }
-       }
-
-       /**
-        * Get the translation contributors for the given locale.
-        *
-        * @param GP_Locale $locale
-        * @return array
-        */
-       private function get_translation_contributors( $locale, $max_age_days = null ) {
-               global $wpdb;
-
-               $contributors = array();
-
-               $date_constraint = '';
-               if ( null !== $max_age_days ) {
-                       $date_constraint = $wpdb->prepare( " AND date_modified >= CURRENT_DATE - INTERVAL %d DAY", $max_age_days );
-               }
-
-               [ $locale, $locale_slug ] = array_merge( explode( '/', $locale->slug ), [ 'default' ] );
-
-               $users = $wpdb->get_col( $wpdb->prepare(
-                       "SELECT DISTINCT user_id FROM translate_user_translations_count WHERE accepted > 0 AND locale = %s AND locale_slug = %s",
-                       $locale,
-                       $locale_slug
-               ) . $date_constraint );
-
-               if ( ! $users ) {
-                       return $contributors;
-               }
-
-               $user_data = $wpdb->get_results( "SELECT user_nicename, display_name, user_email FROM $wpdb->users WHERE ID IN (" . implode( ',', $users ) . ")" );
-               foreach ( $user_data as $user ) {
-                       if ( $user->display_name && $user->display_name !== $user->user_nicename ) {
-                               $contributors[ $user->user_nicename ] = array(
-                                       'display_name' => $user->display_name,
-                                       'nice_name'    => $user->user_nicename,
-                               );
-                       } else {
-                               $contributors[ $user->user_nicename ] = array(
-                                       'display_name' => $user->user_nicename,
-                                       'nice_name'    => $user->user_nicename,
-                               );
-                       }
-               }
-
-               uasort( $contributors, array( $this, '_sort_display_name_callback' ) );
-
-               return $contributors;
-       }
-
-       /**
-        * Determine the release status of the given locale,
-        *
-        * @param string $rosetta_site_url
-        * @param string $latest_release
-        *
-        * @return string
-        */
-       protected static function get_locale_release_status( $rosetta_site_url, $latest_release ) {
-               if ( ! $rosetta_site_url ) {
-                       return 'no-site';
-               }
-
-               if ( ! $latest_release ) {
-                       return 'no-releases';
-               }
-
-               $one_lower = floatval( WP_CORE_LATEST_RELEASE ) - 0.1;
-
-               if ( $latest_release == WP_CORE_LATEST_RELEASE ) {
-                       return 'latest';
-               } elseif ( substr( $latest_release, 0, 3 ) == substr( WP_CORE_LATEST_RELEASE, 0, 3 ) ) {
-                       return 'minor-behind';
-               } elseif ( substr( $latest_release, 0, 3 ) == substr( $one_lower, 0, 3 ) ) {
-                       return 'major-behind-one';
-               } else {
-                       return 'major-behind-many';
-               }
-       }
-
-       /**
-        * Determine the translation status of the given locale.
-        *
-        * @param int $percent_translated
-        *
-        * @return string
-        */
-       protected static function get_locale_translation_status( $percent_translated ) {
-               if ( $percent_translated == 100 ) {
-                       return 'translated-100';
-               } elseif ( $percent_translated >= 95 ) {
-                       return 'translated-95';
-               } elseif ( $percent_translated >= 90 ) {
-                       return 'translated-90';
-               } elseif ( $percent_translated >= 50 ) {
-                       return 'translated-50';
-               } else {
-                       return 'translated-50-less';
-               }
-       }
-
-       /**
-        * Get the Slack username for a .org user.
-        *
-        * @param int $user_id
-        *
-        * @return string
-        */
-       protected static function get_slack_username( $user_id ) {
-               global $wpdb;
-
-               $slack_username = '';
-
-               $data = $wpdb->get_var( $wpdb->prepare( "SELECT profiledata FROM slack_users WHERE user_id = %d", $user_id ) );
-               if ( $data && ( $data = json_decode( $data, true ) ) ) {
-                       if ( !empty( $data['profile']['display_name'] ) && empty( $data['deleted'] ) ) {
-                               // Optional Display Name field.
-                               $slack_username = $data['profile']['display_name'];
-                       } elseif ( !empty( $data['profile']['real_name'] ) && empty( $data['deleted'] ) ) {
-                               // Fall back to "Full Name" field.
-                               $slack_username = $data['profile']['real_name'];
-                       }
-               }
-
-               return $slack_username;
-       }
-
-       public function _sort_display_name_callback( $a, $b ) {
-               return strnatcasecmp( $a['display_name'], $b['display_name'] );
-       }
-}
-
-$GLOBALS['wp_i18n_teams'] = new WP_I18n_Teams();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+bootstrap();
</ins></span></pre>
</div>
</div>

</body>
</html>