r53720 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r53719‎ | r53720 | r53721 >
Date:17:41, 24 July 2009
Author:shinjiman
Status:ok
Tags:
Comment:
Tweak the language code display more comply with the BCP 47 standards, using a new global function wfBCP47().
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/config/index.php (modified) (history)
  • /trunk/phase3/includes/GlobalFunctions.php (modified) (history)
  • /trunk/phase3/includes/Preferences.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/GlobalFunctions.php
@@ -3190,3 +3190,22 @@
31913191
31923192 return $array;
31933193 }
 3194+
 3195+/* get the noramised IETF language tag */
 3196+function wfBCP47( $code ) {
 3197+ $codeSegment = explode( '-', $code );
 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
 3207+ $codeBCP[$segNo] = $seg;
 3208+ }
 3209+ $langCode = implode ( '-' , $codeBCP );
 3210+ return $langCode;
 3211+}
 3212+
Index: trunk/phase3/includes/Preferences.php
@@ -208,7 +208,7 @@
209209
210210 $options = array();
211211 foreach( $languages as $code => $name ) {
212 - $display = "$code - $name";
 212+ $display = wfBCP47( $code ) . ' - ' . $name;
213213 $options[$display] = $code;
214214 }
215215 $defaultPreferences['language'] =
@@ -237,7 +237,7 @@
238238
239239 $options = array();
240240 foreach( $variantArray as $code => $name ) {
241 - $display = "$code - $name";
 241+ $display = wfBCP47( $code ) . ' - ' . $name;
242242 $options[$display] = $code;
243243 }
244244
Index: trunk/phase3/config/index.php
@@ -2094,7 +2094,7 @@
20952095 if( preg_match( '/Messages([A-Z][a-z_]+)\.php$/', $f, $m ) ) {
20962096 $code = str_replace( '_', '-', strtolower( $m[1] ) );
20972097 if( isset( $wgLanguageNames[$code] ) ) {
2098 - $name = $code . ' - ' . $wgLanguageNames[$code];
 2098+ $name = wfBCP47( $code ) . ' - ' . $wgLanguageNames[$code];
20992099 } else {
21002100 $name = $code;
21012101 }
Index: trunk/phase3/RELEASE-NOTES
@@ -324,7 +324,9 @@
325325 * (bug 16877) Moving a page over a redirect no longer leaves an orphan entry in
326326 the recentchanges table
327327 * (bug 16009) Limit selection forms based on Pager now links to the correct page
328 - when using long urls
 328+ when using long urls
 329+* The display of the language list on the preferences is more comply with the
 330+ BCP 47 standards.
329331
330332 == API changes in 1.16 ==
331333

Follow-up revisions

RevisionCommit summaryAuthorDate
r53722fix E_NOTICE on r53720 and r53721.shinjiman18:35, 24 July 2009
r53742Tweak to use lowercase on other cases, which follows r53720 and r53722.shinjiman07:23, 25 July 2009

Status & tagging log