Making WordPress.org

Changeset 812


Ignore:
Timestamp:
08/26/2014 03:21:21 AM (10 years ago)
Author:
nacin
Message:

Translations API lib: Serve languages even when they share the same ISO code (like eng).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/api.wordpress.org/public_html/translations/lib.php

    r778 r812  
    7474    }
    7575
     76    $i = 0;
    7677    foreach ( $translations as $translation ) {
    7778        $locale = GP_Locales::by_field( 'wp_locale', $translation->language );
     
    8081        // We'll use ISO codes for sorting.
    8182        if ( $locale->lang_code_iso_639_1 ) {
    82             $iso = $isos[1] = $locale->lang_code_iso_639_1;
     83            $key = $isos[1] = $locale->lang_code_iso_639_1;
    8384        }
    8485        if ( $locale->lang_code_iso_639_2 ) {
    85             $iso = $isos[2] = $locale->lang_code_iso_639_2;
     86            $key = $isos[2] = $locale->lang_code_iso_639_2;
    8687        }
    8788        if ( $locale->lang_code_iso_639_3 ) {
    88             $iso = $isos[3] = $locale->lang_code_iso_639_3;
     89            $key = $isos[3] = $locale->lang_code_iso_639_3;
    8990        }
    9091
     
    9394        }
    9495
    95         $_translations[ $iso ] = $translation;
    96         $_translations[ $iso ]->english_name = $locale->english_name;
    97         $_translations[ $iso ]->native_name = $locale->native_name;
    98         $_translations[ $iso ]->package = sprintf( "$base_url/%s/%s.zip", $translation->version, $translation->language );
    99         $_translations[ $iso ]->iso = (object) $isos;
     96        // ISO codes are being used for sorting. Don't let variants stomp on each other.
     97        if ( isset( $_translations[ $key ] ) ) {
     98            $key .= ++$i;
     99        }
     100   
     101        $_translations[ $key ] = $translation;
     102        $_translations[ $key ]->english_name = $locale->english_name;
     103        $_translations[ $key ]->native_name = $locale->native_name;
     104        $_translations[ $key ]->package = sprintf( "$base_url/%s/%s.zip", $translation->version, $translation->language );
     105        $_translations[ $key ]->iso = (object) $isos;
    100106
    101107        if ( 'core' === $type ) {
    102108            $continue = isset( $continue_translations[ $locale->slug ] ) ? $continue_translations[ $locale->slug ]->translation : '';
    103             $_translations[ $iso ]->strings = (object) array( 'continue' => $continue );
     109            $_translations[ $key ]->strings = (object) array( 'continue' => $continue );
    104110        }
    105111    }
Note: See TracChangeset for help on using the changeset viewer.