From 04ecbe56cb1218c4af402170f64b3437a1c9b532 Mon Sep 17 00:00:00 2001 From: Liangent Date: Sun, 18 Nov 2012 04:00:12 +0800 Subject: [PATCH] Use wfBCP47() to format language code for IE in Accept-Language. 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 | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/includes/OutputPage.php b/includes/OutputPage.php index ab7e62fa8f..8399a8cde6 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -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; } } } -- 2.20.1