Index: trunk/phase3/includes/GlobalFunctions.php |
— | — | @@ -3195,15 +3195,20 @@ |
3196 | 3196 | function wfBCP47( $code ) { |
3197 | 3197 | $codeSegment = explode( '-', $code ); |
3198 | 3198 | foreach ( $codeSegment as $segNo => $seg ) { |
3199 | | - // ISO 3166 country code |
3200 | | - if ( ( strlen( $seg ) == 2 ) && ( $segNo > 0 ) ) |
3201 | | - $codeBCP[$segNo] = strtoupper ( $seg ); |
3202 | | - // ISO 15924 script code |
3203 | | - else if ( ( strlen( $seg ) == 4 ) && ( $segNo > 0 ) ) |
3204 | | - $codeBCP[$segNo] = ucfirst( $seg ); |
3205 | | - // Keep casing for other cases |
3206 | | - else |
| 3199 | + if ( count( $codeSegment ) > 0 ) { |
| 3200 | + // ISO 3166 country code |
| 3201 | + if ( ( strlen( $seg ) == 2 ) && ( $segNo > 0 ) ) |
| 3202 | + $codeBCP[$segNo] = strtoupper ( $seg ); |
| 3203 | + // ISO 15924 script code |
| 3204 | + else if ( ( strlen( $seg ) == 4 ) && ( $segNo > 0 ) ) |
| 3205 | + $codeBCP[$segNo] = ucfirst( $seg ); |
| 3206 | + else |
| 3207 | + // Keep casing for other cases |
| 3208 | + $codeBCP[$segNo] = $seg; |
| 3209 | + } else { |
| 3210 | + // Keep casing for single segment |
3207 | 3211 | $codeBCP[$segNo] = $seg; |
| 3212 | + } |
3208 | 3213 | } |
3209 | 3214 | $langCode = implode ( '-' , $codeBCP ); |
3210 | 3215 | return $langCode; |