Changeset 12873
- Timestamp:
- 08/31/2023 10:50:11 AM (2 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-translation-suggestions
- Files:
-
- 3 edited
-
css/translation-suggestions.css (modified) (1 diff)
-
inc/class-plugin.php (modified) (2 diffs)
-
js/translation-suggestions.js (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-translation-suggestions/css/translation-suggestions.css
r12510 r12873 104 104 background: #B5E1B9; 105 105 } 106 107 .translation-suggestion__footer_message__for_suggestions { 108 font-size: 12px; 109 } -
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-translation-suggestions/inc/class-plugin.php
r12751 r12873 173 173 $query_tm = mb_strlen( $entry->singular ) <= 420; 174 174 175 // Used to add a link to add the OpenAI and the DeepL keys. 176 // We only show this link if the user has not added any of these keys yet. 177 $gp_default_sort = get_user_option( 'gp_default_sort' ); 178 $openai_key = trim( gp_array_get( $gp_default_sort, 'openai_api_key' ) ); 179 $deepl_key = trim( gp_array_get( $gp_default_sort, 'deepl_api_key' ) ); 175 180 ?> 176 181 <details open class="suggestions__translation-memory<?php echo $query_tm ? '' : ' initialized'; ?>" data-nonce="<?php echo esc_attr( wp_create_nonce( 'translation-memory-suggestions-' . $entry->original_id ) ); ?>"> … … 181 186 <p class="no-suggestions">No suggestions.</p> 182 187 <?php endif; ?> 188 189 <?php if ( empty( $openai_key ) && empty( $deepl_key ) ) : ?> 190 <p class="translation-suggestion__footer_message__for_suggestions">Get translation suggestions from <a href="https://translate.wordpress.org/settings/" target="_blank">OpenAI</a> and from <a href="https://translate.wordpress.org/settings/" target="_blank">DeepL</a>. <a href="https://make.wordpress.org/polyglots/2023/03/29/adding-chatgpt-and-deepl-in-the-translation-memory/" target="_blank">More info</a>.</p> 191 <?php endif; ?> 183 192 </details> 184 193 -
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-translation-suggestions/js/translation-suggestions.js
r12765 r12873 28 28 * Stores the external translations used. 29 29 * @type {object} 30 */30 */ 31 31 var externalSuggestion = {}; 32 32 … … 63 63 $container.append( cachedSuggestion ); 64 64 removeNoSuggestionsMessage( $container ); 65 moveFooterToTheBottom( $container ); 65 66 copyTranslationMemoryToSidebarTab( $container ); 66 67 return; … … 85 86 storeTheSuggestionInTheCache( type, originalId, response.data ); 86 87 removeNoSuggestionsMessage( $container ); 88 moveFooterToTheBottom( $container ); 87 89 copyTranslationMemoryToSidebarTab( $container ); 88 90 } else { … … 196 198 function copyTranslationMemoryToSidebarTab( $container ){ 197 199 var editor = $container.closest( '.editor' ); 198 var divSidebarWithTM = editor.find( '.meta.translation-memory' ).first();200 var divSidebarWithTM = editor.find( '.meta.translation-memory' ).first(); 199 201 var divId = divSidebarWithTM.attr( 'data-row-id' ); 200 202 var TMcontainer = editor.find( '.suggestions__translation-memory' ); … … 358 360 removeNoSuggestionsDuplicateMessage( $container ); 359 361 } 362 } 363 364 /** 365 * Moves the footer with the link to OpenAI and DeepL to the bottom of the container. 366 * 367 * This is needed because the suggestions are loaded asynchronously. 368 * 369 * @param {object} $container The container where the suggestions are stored. 370 * 371 * @return {void} 372 */ 373 function moveFooterToTheBottom( $container ) { 374 var footer = $container.find( '.translation-suggestion__footer_message__for_suggestions' ); 375 if ( ! footer ) { 376 return; 377 } 378 $container.append( footer ); 360 379 } 361 380
Note: See TracChangeset
for help on using the changeset viewer.