Index: /sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-routes/cli/update-caches.php
===================================================================
--- /sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-routes/cli/update-caches.php (revision 2279)
+++ /sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-routes/cli/update-caches.php (revision 2280)
@@ -11,4 +11,5 @@
$this->contributors_count();
$this->translation_status();
+ $this->existing_locales();
}
@@ -68,3 +69,15 @@
WP_CLI::success( 'Translation status was updated.' );
}
+
+ /**
+ * Update cache for existing locales.
+ *
+ * @subcommand existing-locales
+ */
+ public function existing_locales() {
+ $existing_locales = GP::$translation_set->existing_locales();
+
+ wp_cache_set( 'existing-locales', $existing_locales, $this->cache_group );
+ WP_CLI::success( 'Existing locales were updated.' );
+ }
}
Index: /sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-routes/routes/index.php
===================================================================
--- /sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-routes/routes/index.php (revision 2279)
+++ /sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-routes/routes/index.php (revision 2280)
@@ -7,10 +7,18 @@
class WPorg_GP_Route_Index extends GP_Route {
+ private $cache_group = 'wporg-translate';
+
/**
* Prints all exisiting locales as cards.
+ *
+ * Note: Cache gets refreshed via `WPorg_GP_CLI_Update_Caches`.
*/
public function get_locales() {
+ $existing_locales = wp_cache_get( 'existing-locales', $this->cache_group );
+ if ( false === $existing_locales ) {
+ $existing_locales = array();
+ }
+
$locales = array();
- $existing_locales = GP::$translation_set->existing_locales();
foreach ( $existing_locales as $locale ) {
$locales[] = GP_Locales::by_slug( $locale );
@@ -19,10 +27,10 @@
unset( $existing_locales );
- $contributors_count = wp_cache_get( 'contributors-count', 'wporg-translate' );
+ $contributors_count = wp_cache_get( 'contributors-count', $this->cache_group );
if ( false === $contributors_count ) {
$contributors_count = array();
}
- $translation_status = wp_cache_get( 'translation-status', 'wporg-translate' );
+ $translation_status = wp_cache_get( 'translation-status', $this->cache_group );
if ( false === $translation_status ) {
$translation_status = array();