Making WordPress.org

Changeset 7080


Ignore:
Timestamp:
04/10/2018 05:29:44 PM (6 years ago)
Author:
coreymckrill
Message:

WP15 locales: Use the correct locale string in the contribute URL

Fixes #3561

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wp15.wordpress.net/public_html/content/mu-plugins/locales.php

    r7079 r7080  
    4444    }
    4545
    46     $locale_status = wp_list_pluck( $translation_sets, 'percent_translated', 'wp_locale' );
    47     update_option( 'wp15_locale_status', $locale_status );
     46    update_option( 'wp15_locale_data', $translation_sets );
    4847
    4948    foreach ( $translation_sets as $set ) {
     
    213212 */
    214213function locale_notice() {
     214    $locale_data = get_option( 'wp15_locale_data', array() );
     215
     216    if ( empty( $locale_data ) ) {
     217        return;
     218    }
     219
    215220    $current_locale = get_locale();
    216     $status         = get_option( 'wp15_locale_status', array() );
     221    $statuses       = wp_list_pluck( $locale_data, 'percent_translated', 'wp_locale' );
     222    $mapped_locales = wp_list_pluck( $locale_data, 'locale', 'wp_locale' );
    217223    $threshold      = 90;
    218224    $is_dismissed   = ! empty( $_COOKIE['wp15-locale-notice-dismissed'] );
    219225
    220     if ( isset( $status[ $current_locale ] ) && absint( $status[ $current_locale ] ) <= $threshold && ! $is_dismissed ) : ?>
     226    if ( isset( $statuses[ $current_locale ] ) && absint( $statuses[ $current_locale ] ) <= $threshold && ! $is_dismissed ) :
     227        $contribute_url = 'https://translate.wordpress.org/projects/meta/wp15/';
     228
     229        if ( isset( $mapped_locales[ $current_locale ] ) ) {
     230            $contribute_url .= $mapped_locales[ $current_locale ] . '/default';
     231        }
     232    ?>
    221233        <div class="wp15-locale-notice">
    222234            <p>
    223235                <?php
    224236                printf(
     237                    /* translators: %s placeholder is a URL. */
    225238                    wp_kses_post( __( 'The translation for this locale is incomplete. Help us get to 100 percent by <a href="%s">contributing a translation</a>.', 'wp15' ) ),
    226                     esc_url( sprintf(
    227                         'https://translate.wordpress.org/projects/meta/wp15/%s/default',
    228                         strtolower( str_replace( '_', '-', $current_locale ) )
    229                     ) )
     239                    esc_url( $contribute_url )
    230240                );
    231241                ?>
Note: See TracChangeset for help on using the changeset viewer.