WordPress.org

Making WordPress.org

Changeset 4490


Ignore:
Timestamp:
12/06/2016 06:12:53 PM (4 years ago)
Author:
ocean90
Message:

Credits API: Add support for language variants.

Fixes #1768.

Location:
sites/trunk/api.wordpress.org/public_html/core/credits
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/api.wordpress.org/public_html/core/credits/index.php

    r2291 r4490  
    4444if ( ( isset( $_GET['locale'] ) && 'en_US' != $_GET['locale'] ) || ( 'cli' == php_sapi_name() && isset( $argv[2] ) ) ) {
    4545    require GLOTPRESS_LOCALES_PATH;
     46
     47    // Temporary: Add language variants to the list of GlotPress locales.
     48    $GLOBALS['gp_locales'] = new GP_Locales();
     49
     50    $de_formal = clone GP_Locales::by_field( 'wp_locale', 'de_DE' );
     51    $de_formal->english_name = 'German (Formal)';
     52    $de_formal->native_name = 'Deutsch (Sie)';
     53    $de_formal->slug = 'de/formal';
     54    $de_formal->wp_locale = 'de_DE_formal';
     55    $GLOBALS['gp_locales']->locales['de/formal'] = $de_formal;
     56
     57    $nl_formal = clone GP_Locales::by_field( 'wp_locale', 'nl_NL' );
     58    $nl_formal->english_name = 'Dutch (Formal)';
     59    $nl_formal->native_name = 'Nederlands (Formeel)';
     60    $nl_formal->slug = 'nl/formal';
     61    $nl_formal->wp_locale = 'nl_NL_formal';
     62    $GLOBALS['gp_locales']->locales['nl/formal'] = $nl_formal;
     63
     64    $de_ch_informal = clone GP_Locales::by_field( 'wp_locale', 'de_CH' );
     65    $de_ch_informal->english_name = 'German (Switzerland, Informal)';
     66    $de_ch_informal->native_name = 'Deutsch (Schweiz, Du)';
     67    $de_ch_informal->slug = 'de-ch/informal';
     68    $de_ch_informal->wp_locale = 'de_CH_informal';
     69    $GLOBALS['gp_locales']->locales['de-ch/informal'] = $de_ch_informal;
     70
    4671    $gp_locale = GP_Locales::by_field( 'wp_locale', isset( $argv[2] ) ? $argv[2] : $_GET['locale'] );
    4772    if ( $gp_locale ) {
  • sites/trunk/api.wordpress.org/public_html/core/credits/wp-credits.php

    r4489 r4490  
    143143        $path = 'wp/' . $path;
    144144
    145         $locale = $gp_locale->slug;
     145        $locale_parts = explode( '/', $gp_locale->slug );
     146        $locale = $locale_parts[0];
     147        $slug   = isset( $locale_parts[1] ) ? $locale_parts[1] : 'default';
    146148
    147149        $path   = $wpdb->escape( like_escape( $path ) . '%' );
    148150        $locale = $wpdb->escape( $locale );
     151        $slug   = $wpdb->escape( $slug );
    149152
    150153        $date = $wpdb->prepare( "AND tt.date_added > %s", $this->get_start_date() );
     
    160163            WHERE tp.path LIKE '$path'
    161164                AND tts.locale = '$locale'
    162                 AND tts.slug = 'default'
     165                AND tts.slug = '$slug'
    163166                AND ( tt.status = 'current' || tt.status = 'old' )
    164167                AND tt.user_id IS NOT NULL
     
    220223        $project_ids[] = '0'; // Global validators
    221224
     225        $locale_parts = explode( '/', $gp_locale->slug );
     226        $locale = $locale_parts[0];
     227
    222228        return $wpdb->get_col( $wpdb->prepare( "
    223229            SELECT `user_id` FROM `translate_translation_editors`
    224230            WHERE `project_id` IN (" . implode( ', ', $project_ids ) . ") AND `locale` = %s
    225         ", $gp_locale->slug ) );
     231        ", $locale ) );
    226232    }
    227233
Note: See TracChangeset for help on using the changeset viewer.