Changeset 12583
- Timestamp:
- 05/12/2023 08:05:07 AM (3 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-customizations/templates
- Files:
-
- 3 edited
-
js/editor.js (modified) (3 diffs)
-
style.css (modified) (2 diffs)
-
translation-row-editor.php (modified) (17 diffs)
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-customizations/templates/js/editor.js
r12511 r12583 1 /* global $gp */ 1 2 ( function( $ ){ 2 3 var $html = $( 'html' ); … … 300 301 } 301 302 } 303 // Click on the last tab opened in the previous row, to show the same tab in the current row. 304 $gp.editor.current.find( '.' + states['last-tab-type-open'] ).first().click(); 305 } 306 307 function changeRightTab( event ) { 308 var tab = $( this ); 309 var tabType = tab.attr( 'class' ).split(' ')[0]; 310 var tabId = tab.attr( 'data-tab' ); 311 var divId = tabId.replace( 'tab', 'div' ); 312 var originalId = tabId.replace( /[^\d-]/g, '' ).replace( /^-+/g, '' ); 313 changeVisibleTab( tab ); 314 changeVisibleDiv( divId, originalId ); 315 updateDetailsState( 'last-tab-type-open', tabType ); 316 // Avoid to execute the code from the gp-translation-helpers plugin. 317 event.stopImmediatePropagation(); 318 } 319 320 /** 321 * Hides all tabs and show one of them, the last clicked. 322 * 323 * @param {Object} tab The selected tab. 324 */ 325 function changeVisibleTab( tab ) { 326 var tabId = tab.attr( 'data-tab' ); 327 tab.siblings().removeClass( 'current' ); 328 tab.parents( '.sidebar-tabs ' ).find( '.helper' ).removeClass( 'current' ); 329 tab.addClass( 'current' ); 330 331 $( '#' + tabId ).addClass( 'current' ); 332 } 333 334 335 /** 336 * Hides all divs and show one of them, the last clicked. 337 * 338 * @param {string} tabId The select tab id. 339 * @param {number} originalId The id of the original string to translate. 340 */ 341 function changeVisibleDiv( tabId, originalId ) { 342 $( '#sidebar-div-meta-' + originalId ).hide(); 343 $( '#sidebar-div-discussion-' + originalId ).hide(); 344 $( '#sidebar-div-history-' + originalId ).hide(); 345 $( '#sidebar-div-other-locales-' + originalId ).hide(); 346 $( '#sidebar-div-translation-memory-' + originalId ).hide(); 347 $( '#' + tabId ).show(); 302 348 } 303 349 … … 330 376 .on( 'click', 'button.button-menu__toggle', toggleLinkMenu ) 331 377 .on( 'click', '.translation-suggestion.with-tooltip.openai', addSuggestion ) 332 .on( 'click', '.translation-suggestion.with-tooltip.deepl', addSuggestion ); 378 .on( 'click', '.translation-suggestion.with-tooltip.deepl', addSuggestion ) 379 .on( 'click', '.sidebar-tabs li', changeRightTab ); 333 380 } 334 381 })( $gp.editor.install_hooks ); -
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-customizations/templates/style.css
r12511 r12583 3148 3148 .meta.discussion, 3149 3149 .meta.history, 3150 .meta.other-locales { 3150 .meta.other-locales, 3151 .meta.translation-memory { 3151 3152 padding: 12px; 3152 3153 } … … 3190 3191 } 3191 3192 3192 .meta.other-locales ul {3193 .meta.other-locales ul, .meta.transation-memory ul { 3193 3194 margin: 0; 3194 3195 padding: 0; 3196 } 3197 3198 .meta.translation-memory ul.suggestions-list { 3199 list-style: none; 3200 margin-left: 0; 3201 } 3202 3203 .meta.translation-memory div.translation-suggestion { 3204 margin: 1rem 0; 3195 3205 } 3196 3206 -
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-customizations/templates/translation-row-editor.php
r12406 r12583 7 7 $more_links = array(); 8 8 if ( $translation->translation_status ) { 9 $translation_permalink = gp_url_project_locale( $project, $locale->slug, $translation_set->slug, array( 'filters[status]' => 'either', 'filters[original_id]' => $translation->original_id, 'filters[translation_id]' => $translation->id ) ); 9 $translation_permalink = gp_url_project_locale( 10 $project, 11 $locale->slug, 12 $translation_set->slug, 13 array( 14 'filters[status]' => 'either', 15 'filters[original_id]' => $translation->original_id, 16 'filters[translation_id]' => $translation->id, 17 ) 18 ); 10 19 $more_links['translation-permalink'] = '<a href="' . esc_url( $translation_permalink ) . '">Permalink to translation</a>'; 11 20 } else { 12 $original_permalink = gp_url_project_locale( $project, $locale->slug, $translation_set->slug, array( 'filters[original_id]' => $translation->original_id ) );21 $original_permalink = gp_url_project_locale( $project, $locale->slug, $translation_set->slug, array( 'filters[original_id]' => $translation->original_id ) ); 13 22 $more_links['original-permalink'] = '<a href="' . esc_url( $original_permalink ) . '">Permalink to original</a>'; 14 23 } 15 24 16 $original_history = gp_url_project_locale( $project, $locale->slug, $translation_set->slug, array( 'filters[status]' => 'either', 'filters[original_id]' => $translation->original_id, 'sort[by]' => 'translation_date_added', 'sort[how]' => 'asc' ) ); 25 $original_history = gp_url_project_locale( 26 $project, 27 $locale->slug, 28 $translation_set->slug, 29 array( 30 'filters[status]' => 'either', 31 'filters[original_id]' => $translation->original_id, 32 'sort[by]' => 'translation_date_added', 33 'sort[how]' => 'asc', 34 ) 35 ); 17 36 $more_links['history'] = '<a href="' . esc_url( $original_history ) . '">Translation History</a>'; 18 37 … … 31 50 ?> 32 51 <tr class="editor <?php echo gp_translation_row_classes( $translation ); ?>" id="editor-<?php echo esc_attr( $translation->row_id ); ?>" row="<?php echo esc_attr( $translation->row_id ); ?>"> 33 <td colspan="<?php echo $can_approve ? 5 : 4 ?>">52 <td colspan="<?php echo $can_approve ? 5 : 4; ?>"> 34 53 <div class="editor-panel"> 35 54 <div class="editor-panel__left"> … … 80 99 $plural = $translation->plural_glossary_markup ?? esc_translation( $translation->plural ); 81 100 82 if ( ! $translation->plural ) : ?> 101 if ( ! $translation->plural ) : 102 ?> 83 103 <div class="source-string__singular"> 84 104 <span class="original"><?php echo prepare_original( $singular ); ?></span> 85 105 <span aria-hidden="true" class="original-raw"><?php echo esc_translation( $translation->singular ); ?></span> 86 106 </div> 87 <?php else : ?>107 <?php else : ?> 88 108 <div class="source-string__singular"> 89 109 <small>Singular:</small> … … 100 120 101 121 <div class="source-details"> 102 <?php if ( wporg_gp_should_display_original_context( $translation ) ) : ?>122 <?php if ( wporg_gp_should_display_original_context( $translation ) ) : ?> 103 123 <details open class="source-details__context"> 104 124 <summary>Context</summary> … … 106 126 </details> 107 127 <?php endif; ?> 108 <?php if ( $translation->extracted_comments ) : 128 <?php 129 if ( $translation->extracted_comments ) : 109 130 ?> 110 131 <details open class="source-details__comment"> … … 155 176 </li> 156 177 <?php else : ?> 157 <?php foreach( range( 0, $locale->nplurals - 1 ) as $plural_index ): 158 $plural_string = implode(', ', $locale->numbers_for_index( $plural_index ) ); 178 <?php 179 foreach ( range( 0, $locale->nplurals - 1 ) as $plural_index ) : 180 $plural_string = implode( ', ', $locale->numbers_for_index( $plural_index ) ); 159 181 ?> 160 182 <li> … … 162 184 class="translation-form-list__tab with-tooltip<?php echo ( 0 === $plural_index ) ? ' translation-form-list__tab--active' : ''; ?>" 163 185 data-plural-index="<?php echo $plural_index; ?>" 164 aria-label="<?php printf( 'This plural form is used for numbers like: %s', $plural_string ); ?>"186 aria-label="<?php printf( 'This plural form is used for numbers like: %s', $plural_string ); ?>" 165 187 type="button"> 166 188 <?php echo $plural_string; ?> … … 174 196 175 197 <?php if ( ! $translation->plural ) : ?> 176 <?php wporg_gp_translate_textarea( $translation, [ $can_edit, $can_approve_translation ]); ?>198 <?php wporg_gp_translate_textarea( $translation, array( $can_edit, $can_approve_translation ) ); ?> 177 199 <?php else : ?> 178 <?php foreach ( range( 0, $locale->nplurals - 1 ) as $plural_index ): ?>179 <?php wporg_gp_translate_textarea( $translation, [ $can_edit, $can_approve ], $plural_index ); ?>200 <?php foreach ( range( 0, $locale->nplurals - 1 ) as $plural_index ) : ?> 201 <?php wporg_gp_translate_textarea( $translation, array( $can_edit, $can_approve ), $plural_index ); ?> 180 202 <?php endforeach; ?> 181 203 <?php endif; ?> … … 240 262 <div class="editor-panel__right"> 241 263 <!-- <div class="panel-header"> 242 <h3><?php /*_e( 'Meta', 'glotpress' ); */ ?></h3>264 <h3><?php /*_e( 'Meta', 'glotpress' ); */ ?></h3> 243 265 </div>--> 244 266 <div class="panel-content"> 245 267 <?php ob_start(); ?> 246 <div class="meta" id="sidebar-div-meta-<?php echo $translation->row_id?>">268 <div class="meta" id="sidebar-div-meta-<?php echo $translation->row_id; ?>"> 247 269 <?php gp_tmpl_load( 'translation-row-editor-meta-feedback', get_defined_vars() ); ?> 248 <?php if ( $translation->translation_status && ( $can_approve_translation || $can_reject_self ) ) : ?>270 <?php if ( $translation->translation_status && ( $can_approve_translation || $can_reject_self ) ) : ?> 249 271 <div class="status-actions"> 250 272 <?php if ( $can_approve_translation ) : ?> … … 261 283 <button class="button fuzzy" tabindex="-1" data-nonce="<?php echo esc_attr( wp_create_nonce( 'update-translation-status-fuzzy_' . $translation->id ) ); ?>"><strong>~</strong> <?php _e( 'Fuzzy', 'glotpress' ); ?></button> 262 284 <?php endif; ?> 263 <?php elseif ( $can_reject_self ) : ?>285 <?php elseif ( $can_reject_self ) : ?> 264 286 <button class="button reject" tabindex="-1" data-nonce="<?php echo esc_attr( wp_create_nonce( 'update-translation-status-rejected_' . $translation->id ) ); ?>"><strong>−</strong> <?php _e( 'Reject Suggestion', 'glotpress' ); ?></button> 265 287 <button class="button fuzzy" tabindex="-1" data-nonce="<?php echo esc_attr( wp_create_nonce( 'update-translation-status-fuzzy_' . $translation->id ) ); ?>"><strong>~</strong> <?php _e( 'Fuzzy', 'glotpress' ); ?></button> … … 275 297 </dl> 276 298 277 <?php if ( $translation->translation_added && $translation->translation_added !== '0000-00-00 00:00:00' ) : ?>299 <?php if ( $translation->translation_added && $translation->translation_added !== '0000-00-00 00:00:00' ) : ?> 278 300 <dl> 279 301 <dt><?php _e( 'Added:', 'glotpress' ); ?></dt> … … 281 303 </dl> 282 304 <?php endif; ?> 283 <?php if ( $translation->date_modified && $translation->date_modified !== '0000-00-00 00:00:00' && $translation->date_modified !== $translation->translation_added ) : ?>305 <?php if ( $translation->date_modified && $translation->date_modified !== '0000-00-00 00:00:00' && $translation->date_modified !== $translation->translation_added ) : ?> 284 306 <dl> 285 307 <dt><?php _e( 'Last modified:', 'glotpress' ); ?></dt> … … 295 317 <?php if ( $translation->user_last_modified && ( ! $translation->user || $translation->user->ID !== $translation->user_last_modified->ID ) ) : ?> 296 318 <dl> 297 <dt><?php 298 if ( 'current' === $translation->translation_status ) { 299 _e( 'Approved by:', 'glotpress' ); 300 } elseif ( 'rejected' === $translation->translation_status ) { 301 _e( 'Rejected by:', 'glotpress' ); 302 } else { 303 _e( 'Last updated by:', 'glotpress' ); 304 } 305 ?> 319 <dt> 320 <?php 321 if ( 'current' === $translation->translation_status ) { 322 _e( 'Approved by:', 'glotpress' ); 323 } elseif ( 'rejected' === $translation->translation_status ) { 324 _e( 'Rejected by:', 'glotpress' ); 325 } else { 326 _e( 'Last updated by:', 'glotpress' ); 327 } 328 ?> 306 329 </dt> 307 330 <dd><?php gp_link_user( $translation->user_last_modified ); ?></dd> … … 311 334 <dl> 312 335 <dt><?php _e( 'Priority of the original:', 'glotpress' ); ?></dt> 313 <?php if ( $can_write ): ?> 314 <dd><?php 336 <?php if ( $can_write ) : ?> 337 <dd> 338 <?php 315 339 echo gp_select( 316 340 'priority-' . $translation->original_id, … … 323 347 ) 324 348 ); 325 ?></dd> 349 ?> 350 </dd> 326 351 <?php else : ?> 327 352 <dd><?php echo gp_array_get( GP::$original->get_static( 'priorities' ), $translation->priority, 'unknown' ); ?></dd> … … 338 363 $sidebar_tabs .= ' <li class="tab-history" data-tab="sidebar-tab-history-' . $translation->row_id . '" data-row-id="' . $translation->row_id . '">History <span class="count"></span></li>'; 339 364 $sidebar_tabs .= ' <li class="tab-other-locales" data-tab="sidebar-tab-other-locales-' . $translation->row_id . '" data-row-id="' . $translation->row_id . '">Other locales <span class="count"></span></li>'; 365 $sidebar_tabs .= ' <li class="tab-translation-memory" data-tab="sidebar-tab-translation-memory-' . $translation->row_id . '" data-row-id="' . $translation->row_id . '">TM <span class="count"></span></li>'; 340 366 $sidebar_tabs .= '</ul>'; 341 367 $sidebar_tabs .= $meta_sidebar; … … 343 369 $sidebar_tabs .= '<div class="meta history" id="sidebar-div-history-' . $translation->row_id . '" data-row-id="' . $translation->row_id . '" style="display: none;"></div>'; 344 370 $sidebar_tabs .= '<div class="meta other-locales" id="sidebar-div-other-locales-' . $translation->row_id . '" data-row-id="' . $translation->row_id . '" style="display: none;"></div>'; 371 $sidebar_tabs .= '<div class="meta translation-memory" id="sidebar-div-translation-memory-' . $translation->row_id . '" data-row-id="' . $translation->row_id . '" style="display: none;"></div>'; 345 372 $sidebar_tabs .= '</nav>'; 346 373
Note: See TracChangeset
for help on using the changeset viewer.