Making WordPress.org

Changeset 11093


Ignore:
Timestamp:
07/05/2021 07:39:12 PM (3 years ago)
Author:
ocean90
Message:

Translate: Prevent querying the translation memory for long and too unique strings which are not returning results.

Fixes #5804.

Location:
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-translation-suggestions/inc
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-translation-suggestions/inc/class-plugin.php

    r10357 r11093  
    147147        }
    148148
     149
     150        // Prevent querying the TM for long strings which usually time out
     151        // and have no results due to being too unique.
     152        $query_tm = mb_strlen( $entry->singular ) <= 420;
     153
    149154        ?>
    150         <details open class="suggestions__translation-memory" data-nonce="<?php echo esc_attr( wp_create_nonce( 'translation-memory-suggestions-' . $entry->original_id ) ); ?>">
     155        <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 ) ); ?>">
    151156            <summary>Suggestions from Translation Memory</summary>
    152             <p class="suggestions__loading-indicator">Loading <span aria-hidden="true" class="suggestions__loading-indicator__icon"><span></span><span></span><span></span></span></p>
     157            <?php if ( $query_tm ) : ?>
     158                <p class="suggestions__loading-indicator">Loading <span aria-hidden="true" class="suggestions__loading-indicator__icon"><span></span><span></span><span></span></span></p>
     159            <?php else : ?>
     160                <p class="no-suggestions">No suggestions.</p>
     161            <?php endif; ?>
    153162        </details>
    154163
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-translation-suggestions/inc/class-translation-memory-client.php

    r8937 r11093  
    112112            $url,
    113113            [
    114                 'timeout'    => 2,
     114                'timeout'    => 4,
    115115                'user-agent' => 'WordPress.org Translate',
    116116            ]
Note: See TracChangeset for help on using the changeset viewer.