Revision: 53720
Author:   shinjiman
Date:     2009-07-24 17:41:01 +0000 (Fri, 24 Jul 2009)

Log Message:
-----------
Tweak the language code display more comply with the BCP 47 standards, using a 
new global function wfBCP47().

Modified Paths:
--------------
    trunk/phase3/RELEASE-NOTES
    trunk/phase3/config/index.php
    trunk/phase3/includes/GlobalFunctions.php
    trunk/phase3/includes/Preferences.php

Modified: trunk/phase3/RELEASE-NOTES
===================================================================
--- trunk/phase3/RELEASE-NOTES  2009-07-24 16:20:32 UTC (rev 53719)
+++ trunk/phase3/RELEASE-NOTES  2009-07-24 17:41:01 UTC (rev 53720)
@@ -324,7 +324,9 @@
 * (bug 16877) Moving a page over a redirect no longer leaves an orphan entry in
   the recentchanges table
 * (bug 16009) Limit selection forms based on Pager now links to the correct 
page
-  when using long urls 
+  when using long urls
+* The display of the language list on the preferences is more comply with the 
+  BCP 47 standards.
 
 == API changes in 1.16 ==
 

Modified: trunk/phase3/config/index.php
===================================================================
--- trunk/phase3/config/index.php       2009-07-24 16:20:32 UTC (rev 53719)
+++ trunk/phase3/config/index.php       2009-07-24 17:41:01 UTC (rev 53720)
@@ -2094,7 +2094,7 @@
                if( preg_match( '/Messages([A-Z][a-z_]+)\.php$/', $f, $m ) ) {
                        $code = str_replace( '_', '-', strtolower( $m[1] ) );
                        if( isset( $wgLanguageNames[$code] ) ) {
-                               $name = $code . ' - ' . $wgLanguageNames[$code];
+                               $name = wfBCP47( $code ) . ' - ' . 
$wgLanguageNames[$code];
                        } else {
                                $name = $code;
                        }

Modified: trunk/phase3/includes/GlobalFunctions.php
===================================================================
--- trunk/phase3/includes/GlobalFunctions.php   2009-07-24 16:20:32 UTC (rev 
53719)
+++ trunk/phase3/includes/GlobalFunctions.php   2009-07-24 17:41:01 UTC (rev 
53720)
@@ -3190,3 +3190,22 @@
        
        return $array;
 }
+
+/* get the noramised IETF language tag */
+function wfBCP47( $code ) {
+       $codeSegment = explode( '-', $code );
+       foreach ( $codeSegment as $segNo => $seg ) {
+               // ISO 3166 country code
+               if ( ( strlen( $seg ) == 2 ) && ( $segNo > 0 ) )
+                       $codeBCP[$segNo] = strtoupper ( $seg );
+               // ISO 15924 script code
+               else if ( ( strlen( $seg ) == 4 ) && ( $segNo > 0 ) )
+                       $codeBCP[$segNo] = ucfirst( $seg );
+               // Keep casing for other cases
+               else
+                       $codeBCP[$segNo] = $seg;
+       }
+       $langCode = implode ( '-' , $codeBCP );
+       return $langCode;
+}
+

Modified: trunk/phase3/includes/Preferences.php
===================================================================
--- trunk/phase3/includes/Preferences.php       2009-07-24 16:20:32 UTC (rev 
53719)
+++ trunk/phase3/includes/Preferences.php       2009-07-24 17:41:01 UTC (rev 
53720)
@@ -208,7 +208,7 @@
 
                $options = array();
                foreach( $languages as $code => $name ) {
-                       $display = "$code - $name";
+                       $display = wfBCP47( $code ) . ' - ' . $name;
                        $options[$display] = $code;
                }
                $defaultPreferences['language'] =
@@ -237,7 +237,7 @@
 
                        $options = array();
                        foreach( $variantArray as $code => $name ) {
-                               $display = "$code - $name";
+                               $display = wfBCP47( $code ) . ' - ' . $name;
                                $options[$display] = $code;
                        }
 



_______________________________________________
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to