Use wfBCP47() to format language code for IE in Accept-Language.
authorLiangent <liangent@gmail.com>
Sat, 17 Nov 2012 20:00:12 +0000 (04:00 +0800)
committerLiangent <liangent@gmail.com>
Sat, 17 Nov 2012 20:00:12 +0000 (04:00 +0800)
It's reported that IE is actually sending language code in BCP 47
format (like zh-Hans), instead of uppercasing the whole 2nd part.

Change-Id: I6761191f299373d9267660a7eb14dc0b34cd5a38

includes/OutputPage.php

index ab7e62f..8399a8c 100644 (file)
@@ -1769,14 +1769,12 @@ class OutputPage extends ContextSource {
                                } else {
                                        $aloption[] = 'string-contains=' . $variant;
 
-                                       // IE and some other browsers use another form of language code
-                                       // in their Accept-Language header, like "zh-CN" or "zh-TW".
+                                       // IE and some other browsers use BCP 47 standards in
+                                       // their Accept-Language header, like "zh-CN" or "zh-Hant".
                                        // We should handle these too.
-                                       $ievariant = explode( '-', $variant );
-                                       if ( count( $ievariant ) == 2 ) {
-                                               $ievariant[1] = strtoupper( $ievariant[1] );
-                                               $ievariant = implode( '-', $ievariant );
-                                               $aloption[] = 'string-contains=' . $ievariant;
+                                       $variantBCP47 = wfBCP47( $variant );
+                                       if ( $variantBCP47 !== $variant ) {
+                                               $aloption[] = 'string-contains=' . $variantBCP47;
                                        }
                                }
                        }