Changeset 1721
- Timestamp:
- 07/10/2015 05:29:36 PM (9 years ago)
- Location:
- sites/trunk/translate.wordpress.org
- Files:
-
- 1 added
- 4 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/translate.wordpress.org/includes/gp-plugins/wporg-routes/routes/index.php
r1586 r1721 7 7 class GP_WPorg_Route_Index extends GP_Route { 8 8 9 public function get_index() { 10 $this->redirect( gp_url( '/languages' ) ); 9 /** 10 * Prints all exisiting locales as cards. 11 */ 12 public function get_locales() { 13 $locales = array(); 14 $existing_locales = GP::$translation_set->existing_locales(); 15 foreach ( $existing_locales as $locale ) { 16 $locales[] = GP_Locales::by_slug( $locale ); 17 } 18 usort( $locales, array( $this, '_sort_english_name_callback') ); 19 unset( $existing_locales ); 20 21 $contributors_count = wp_cache_get( 'contributors-count', 'wporg-translate' ); 22 if ( false === $contributors_count ) { 23 $contributors_count = array(); 24 } 25 26 $translation_status = wp_cache_get( 'translation-status', 'wporg-translate' ); 27 if ( false === $translation_status ) { 28 $translation_status = array(); 29 } 30 31 $this->tmpl( 'index-locales', get_defined_vars() ); 32 } 33 34 private function _sort_english_name_callback( $a, $b ) { 35 return $a->english_name > $b->english_name; 11 36 } 12 37 } -
sites/trunk/translate.wordpress.org/includes/gp-plugins/wporg-routes/routes/locale.php
r1686 r1721 3 3 * Locale Route Class. 4 4 * 5 * Provides the route for translate.wordpress.org/l anguages.5 * Provides the route for translate.wordpress.org/locale/$locale. 6 6 */ 7 7 class GP_WPorg_Route_Locale extends GP_Route { 8 9 /**10 * Prints all exisiting locales as cards.11 */12 public function get_locales() {13 $locales = array();14 $existing_locales = GP::$translation_set->existing_locales();15 foreach ( $existing_locales as $locale ) {16 $locales[] = GP_Locales::by_slug( $locale );17 }18 usort( $locales, array( $this, '_sort_english_name_callback') );19 unset( $existing_locales );20 21 $contributors_count = wp_cache_get( 'contributors-count', 'wporg-translate' );22 if ( false === $contributors_count ) {23 $contributors_count = array();24 }25 26 $translation_status = wp_cache_get( 'translation-status', 'wporg-translate' );27 if ( false === $translation_status ) {28 $translation_status = array();29 }30 31 $this->tmpl( 'locales', get_defined_vars() );32 }33 8 34 9 /** … … 78 53 $variants = $this->get_locale_variants( $locale_slug, array_keys( $project_status ) ); 79 54 80 $this->tmpl( 'locale ', get_defined_vars() );55 $this->tmpl( 'locale-projects', get_defined_vars() ); 81 56 } 82 57 … … 285 260 return strcasecmp( $a->name, $b->name ); 286 261 } 287 288 private function _sort_english_name_callback( $a, $b ) {289 return $a->english_name > $b->english_name;290 }291 262 } -
sites/trunk/translate.wordpress.org/includes/gp-plugins/wporg-routes/wporg-routes.php
r1684 r1721 1 1 <?php 2 2 /** 3 * This plugins overrides some of the default routes of GlotPress.3 * Register custom routes for translate.wordpress.org. 4 4 * 5 5 * @author ocean90 6 6 */ 7 7 8 require_once __DIR__ . '/routes/redirector.php'; 8 9 require_once __DIR__ . '/routes/index.php'; 9 10 require_once __DIR__ . '/routes/locale.php'; … … 18 19 19 20 public function init() { 21 // Bail for API requests. 22 $request_uri = GP::$router->request_uri(); 23 if ( gp_startswith( $request_uri, '/' . GP::$router->api_prefix . '/' ) ) { 24 return; 25 } 26 20 27 $path = '(.+?)'; 21 28 $locale = '(' . implode( '|', array_map( function( $locale ) { return $locale->slug; }, GP_Locales::locales() ) ) . ')'; 22 29 23 /* 24 * Unset default routes. 25 * The `routes` filter can't be used, see https://glotpress.trac.wordpress.org/ticket/249. 26 */ 30 // Unset default routes. 27 31 unset( GP::$router->urls['/'] ); 28 32 unset( GP::$router->urls["get:/languages/$locale/$path"] ); … … 30 34 unset( GP::$router->urls['get:/languages'] ); 31 35 32 GP::$router->add( '/', array( 'GP_WPorg_Route_Index', 'get_index' ) ); 33 GP::$router->add( "/languages/$locale/$path/$path/$path", array( 'GP_WPorg_Route_Locale', 'get_locale_project' ) ); 34 GP::$router->add( "/languages/$locale/$path/$path", array( 'GP_WPorg_Route_Locale', 'get_locale_projects' ) ); 35 GP::$router->add( "/languages/$locale/$path", array( 'GP_WPorg_Route_Locale', 'get_locale_projects' ) ); 36 GP::$router->add( "/languages/$locale", array( 'GP_WPorg_Route_Locale', 'get_locale_projects' ) ); 37 GP::$router->add( '/languages', array( 'GP_WPorg_Route_Locale', 'get_locales' ) ); 36 // Redirect routes. 37 GP::$router->add( "/languages/$path", array( 'GP_WPorg_Route_Redirector', 'redirect_languages' ) ); 38 GP::$router->add( '/languages', array( 'GP_WPorg_Route_Redirector', 'redirect_languages' ) ); 39 40 // Register custom routes. 41 GP::$router->add( '/', array( 'GP_WPorg_Route_Index', 'get_locales' ) ); 42 GP::$router->add( "/locale/$locale/$path/$path/$path", array( 'GP_WPorg_Route_Locale', 'get_locale_project' ) ); 43 GP::$router->add( "/locale/$locale/$path/$path", array( 'GP_WPorg_Route_Locale', 'get_locale_projects' ) ); 44 GP::$router->add( "/locale/$locale/$path", array( 'GP_WPorg_Route_Locale', 'get_locale_projects' ) ); 45 GP::$router->add( "/locale/$locale", array( 'GP_WPorg_Route_Locale', 'get_locale_projects' ) ); 38 46 } 39 47 } -
sites/trunk/translate.wordpress.org/public_html/gp-templates/index-locales.php
r1706 r1721 30 30 <div class="locale <?php echo 'percent-' . $percent_complete; ?>"> 31 31 <ul class="name"> 32 <li class="english"><?php echo gp_link_get( gp_url_join( gp_url_current(), $locale->slug ), $locale->english_name ) ?></li>33 <li class="native"><?php echo gp_link_get( gp_url_join( gp_url_current(), $locale->slug ), $locale->native_name ) ?></li>34 <li class="code"><?php echo gp_link_get( gp_url_join( gp_url_current(), $locale->slug ), $wp_locale ) ?></li>32 <li class="english"><?php echo gp_link_get( gp_url_join( '/locale', $locale->slug ), $locale->english_name ) ?></li> 33 <li class="native"><?php echo gp_link_get( gp_url_join( '/locale', $locale->slug ), $locale->native_name ) ?></li> 34 <li class="code"><?php echo gp_link_get( gp_url_join( '/locale', $locale->slug ), $wp_locale ) ?></li> 35 35 </ul> 36 36 <div class="contributors"> … … 48 48 <div class="locale-button"> 49 49 <div class="button contribute-button"> 50 <?php echo gp_link_get( gp_url_join( gp_url_current(), $locale->slug ), 'Contribute Translation' ) ?>50 <?php echo gp_link_get( gp_url_join( '/locale', $locale->slug ), 'Contribute Translation' ) ?> 51 51 </div> 52 52 </div> -
sites/trunk/translate.wordpress.org/public_html/gp-templates/locale-project.php
r1685 r1721 3 3 4 4 $breadcrumb = array(); 5 $breadcrumb[] = gp_link_get( '/ languages', __( 'Locales' ) );6 $breadcrumb[] = gp_link_get( gp_url_join( '/l anguages', $locale_slug, $set_slug), esc_html( $locale->english_name ) );5 $breadcrumb[] = gp_link_get( '/', __( 'Locales' ) ); 6 $breadcrumb[] = gp_link_get( gp_url_join( '/locale', $locale_slug, $set_slug), esc_html( $locale->english_name ) ); 7 7 $breadcrumb[] = $sub_project->name; 8 8 gp_breadcrumb( $breadcrumb ); … … 36 36 '<option name="%s" data-project-url="%s"%s>%s</option>', 37 37 $variant, 38 esc_url( gp_url_join( '/l anguages', $locale_slug, $variant, $sub_project->path ) ),38 esc_url( gp_url_join( '/locale', $locale_slug, $variant, $sub_project->path ) ), 39 39 ( $set_slug == $variant ) ? ' selected="selected"' : '', 40 40 ucfirst( $variant ) -
sites/trunk/translate.wordpress.org/public_html/gp-templates/locale-projects.php
r1706 r1721 3 3 4 4 $breadcrumb = array(); 5 $breadcrumb[] = gp_link_get( '/ languages', __( 'Locales' ) );5 $breadcrumb[] = gp_link_get( '/', __( 'Locales' ) ); 6 6 $breadcrumb[] = esc_html( $locale->english_name ); 7 7 gp_breadcrumb( $breadcrumb ); … … 29 29 '<option name="%s" data-project-url="%s"%s>%s</option>', 30 30 $variant, 31 esc_url( gp_url_join( '/l anguages', $locale_slug, $variant, $project->slug ) ),31 esc_url( gp_url_join( '/locale', $locale_slug, $variant, $project->slug ) ), 32 32 ( $set_slug == $variant ) ? ' selected="selected"' : '', 33 33 ucfirst( $variant ) … … 59 59 printf( 60 60 '<li><a href="%s"%s>%s</a></li>', 61 gp_url_join( '/l anguages', $locale_slug, $set_slug, $top_level_project->slug ),61 gp_url_join( '/locale', $locale_slug, $set_slug, $top_level_project->slug ), 62 62 ( $top_level_project->path == $project_path ) ? ' class="current"' : '', 63 63 $top_level_project->name … … 83 83 } 84 84 85 $project_url = gp_url_join( '/l anguages', $locale_slug, $set_slug, $sub_project->path );85 $project_url = gp_url_join( '/locale', $locale_slug, $set_slug, $sub_project->path ); 86 86 87 87 $project_icon = '';
Note: See TracChangeset
for help on using the changeset viewer.