WordPress.org

Making WordPress.org

Changeset 6741


Ignore:
Timestamp:
02/25/2018 04:01:45 PM (2 years ago)
Author:
ocean90
Message:

Translate: Apply capital_P_dangit() on translations.

Props SergeyBiryukov for initial patch.
Fixes #1853.

File:
1 edited

Legend:

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

    r6451 r6741  
    33namespace WordPressdotorg\GlotPress\Customizations;
    44
     5use GP_Translation;
    56use WP_CLI;
    67
     
    4445        add_filter( 'body_class', array( $this, 'wporg_add_make_site_body_class' ) );
    4546        add_filter( 'gp_translation_row_template_more_links', array( $this, 'add_consistency_tool_link' ), 10, 5 );
     47        add_filter( 'gp_translation_prepare_for_save', array( $this, 'apply_capital_P_dangit' ), 10, 2 );
    4648
    4749        // Toolbar.
     
    5961            $this->register_cli_commands();
    6062        }
     63    }
     64
     65    /**
     66     * Applies capital_P_dangit() on translations.
     67     *
     68     * @param array          $args        Translation arguments.
     69     * @param GP_Translation $translation Translation instance.
     70     * @return array Translation arguments.
     71     */
     72    public function apply_capital_P_dangit( $args, GP_Translation $translation ) {
     73        foreach ( range( 0, $translation->get_static( 'number_of_plural_translations' ) - 1 ) as $i ) {
     74            if ( isset( $args[ "translation_$i" ] ) ) {
     75                $args[ "translation_$i" ] = capital_P_dangit( $args[ "translation_$i" ] );
     76            }
     77        }
     78
     79        return $args;
    6180    }
    6281
Note: See TracChangeset for help on using the changeset viewer.