r53722 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r53721‎ | r53722 | r53723 >
Date:18:35, 24 July 2009
Author:shinjiman
Status:ok
Tags:
Comment:
fix E_NOTICE on r53720 and r53721.
Modified paths:
  • /trunk/phase3/includes/GlobalFunctions.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/GlobalFunctions.php
@@ -3195,15 +3195,20 @@
31963196 function wfBCP47( $code ) {
31973197 $codeSegment = explode( '-', $code );
31983198 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
32073211 $codeBCP[$segNo] = $seg;
 3212+ }
32083213 }
32093214 $langCode = implode ( '-' , $codeBCP );
32103215 return $langCode;

Follow-up revisions

RevisionCommit summaryAuthorDate
r53742Tweak to use lowercase on other cases, which follows r53720 and r53722.shinjiman07:23, 25 July 2009

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r53720Tweak the language code display more comply with the BCP 47 standards, using ...shinjiman17:41, 24 July 2009
r53721fix typo on documentationshinjiman17:51, 24 July 2009

Status & tagging log