Making WordPress.org


Ignore:
Timestamp:
09/11/2015 04:55:13 AM (9 years ago)
Author:
dd32
Message:

Translate: Only log translation warnings for translations who are 'current' or 'waiting'. This avoids rejected strings (upon update) being sent.

See #1229

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/translate.wordpress.org/includes/gp-plugins/wporg-log-warnings-to-slack.php

    r1870 r1871  
    3939
    4040    /**
    41      * Logs translation warnings into Slack
     41     * Logs translation warnings into Slack for any newly created translations.
    4242     *
    4343     * @param  GP_Translation $translatiom The just-created translation.
    4444     */
    4545    function translation_created( $translation ) {
    46         if ( $translation->warnings ) {
    47             $this->process_translation_warning( $translation );
     46        if ( ! $translation->warnings ) {
     47            return;
    4848        }
     49
     50        // We only want to trigger for strings which are live, or are for consideration.
     51        if ( ! in_array( $translation->status, array( 'current', 'waiting' ) ) ) {
     52            return;
     53        }
     54
     55        $this->process_translation_warning( $translation );
    4956    }
    5057
     58    /**
     59     * Logs translation warnings into Slack for any existing translations that are updated.
     60     *
     61     * @param  GP_Translation $translatiom The just-created translation.
     62     */
    5163    function translation_saved( $translation ) {
    52         if ( $translation->warnings ) {
    53             $this->process_translation_warning( $translation );
     64        if ( ! $translation->warnings ) {
     65            return;
    5466        }
     67
     68        // We only want to trigger for strings which are live, or are for consideration.
     69        if ( ! in_array( $translation->status, array( 'current', 'waiting' ) ) ) {
     70            return;
     71        }
     72
     73        $this->process_translation_warning( $translation );
    5574    }
    5675
Note: See TracChangeset for help on using the changeset viewer.