Making WordPress.org


Ignore:
Timestamp:
05/02/2020 10:50:07 AM (6 years ago)
Author:
ocean90
Message:

Translate: Split multiple translator comments for an original into separate lines.

File:
1 edited

Legend:

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

    r9555 r9814  
    4646        add_filter( 'gp_translation_row_template_more_links', array( $this, 'add_consistency_tool_link' ), 10, 5 );
    4747        add_filter( 'gp_translation_prepare_for_save', array( $this, 'apply_capital_P_dangit' ), 10, 2 );
     48        add_filter( 'gp_original_extracted_comments', array( $this, 'format_translator_commments' ), 5 );
    4849
    4950        // Cron.
     
    6667            $this->register_cli_commands();
    6768        }
     69    }
     70
     71    /**
     72     * Splits multiple translator comments for an original into separate lines.
     73     */
     74    public function format_translator_commments( $comments ) {
     75        $comment_parts = preg_split( '#(^|\n)translators: #i', $comments, 0, PREG_SPLIT_NO_EMPTY );
     76        if ( ! $comment_parts ) {
     77            return $comments;
     78        }
     79
     80        return implode( '<br/>', $comment_parts );
    6881    }
    6982
Note: See TracChangeset for help on using the changeset viewer.