Making WordPress.org

Changeset 12765


Ignore:
Timestamp:
07/28/2023 03:17:38 PM (3 years ago)
Author:
spiraltee
Message:

Translate: Log other locale suggestions

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

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-translation-suggestions/js/translation-suggestions.js

    r12751 r12765  
    479479            return;
    480480        }
    481         externalSuggestion.suggestion_source = $row.data( 'suggestion-source' ) == 'translation' ? 'tm' : $row.data( 'suggestion-source' );
    482         externalSuggestion.translation = $row.find( '.translation-suggestion__translation' ).text();
    483 
     481        if ( $row.data( 'suggestion-locale' ) ) {
     482            externalSuggestion.suggestion_source = $row.data( 'suggestion-locale' );
     483            externalSuggestion.translation = $row.find( '.translation-suggestion__translation-raw' ).text();
     484        } else {
     485            externalSuggestion.suggestion_source = $row.data( 'suggestion-source' );
     486            externalSuggestion.translation = $row.find( '.translation-suggestion__translation' ).text();
     487        }
    484488    }
    485489
    486490    //Prefilter ajax requests to add external translations used to the request.
    487491    $.ajaxPrefilter( function ( options ) {
    488         const isSuggestionUsed = Object.keys( externalSuggestion ).length  > 0 ? true : false;
    489 
    490         if ( ! externalSuggestion || ! isSuggestionUsed ) {
     492        if ( ! externalSuggestion || ! externalSuggestion.suggestion_source || ! externalSuggestion.translation ) {
    491493            return;
    492494        }
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-translation-suggestions/templates/other-languages-suggestions.php

    r11732 r12765  
    77    foreach ( $suggestions as $suggestion ) {
    88        echo '<li>';
    9         echo '<div class="translation-suggestion with-tooltip" tabindex="0" role="button" aria-pressed="false" aria-label="Copy translation">';
     9        echo '<div class="translation-suggestion with-tooltip" tabindex="0" role="button" data-suggestion-locale="' . esc_html( strtolower( $suggestion['locale'] ) ) . '" aria-pressed="false" aria-label="Copy translation">';
    1010
    1111            echo '<span class="translation-suggestion__translation">';
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-translation-suggestions/templates/translation-memory-suggestions.php

    r12751 r12765  
    55    echo '<ul class="suggestions-list">';
    66    foreach ( $suggestions as $suggestion ) {
     7        $suggestion_type = ( 'translation' === strtolower( $type ) ) ? 'tm' : $type;
     8
    79        echo '<li>';
    8         echo '<div class="translation-suggestion with-tooltip ' . esc_html( strtolower( $type ) ) . '" tabindex="0" data-suggestion-source="' . esc_html( strtolower( $type ) ) . '" role="button" aria-pressed="false" aria-label="Copy translation">';
     10        echo '<div class="translation-suggestion with-tooltip ' . esc_html( strtolower( $type ) ) . '" tabindex="0" data-suggestion-source="' . esc_html( strtolower( $suggestion_type ) ) . '" role="button" aria-pressed="false" aria-label="Copy translation">';
    911            echo '<span class="' . esc_html( strtolower( $type ) ) . '-suggestion__score">';
    1012        if ( 'Translation' == $type ) {
Note: See TracChangeset for help on using the changeset viewer.