Index: trunk/phase3/languages/LanguageConverter.php |
— | — | @@ -184,8 +184,17 @@ |
185 | 185 | // preference is loaded |
186 | 186 | if( array_key_exists( 'HTTP_ACCEPT_LANGUAGE', $_SERVER ) ) { |
187 | 187 | $acceptLanguage = str_replace( '_', '-', strtolower($_SERVER["HTTP_ACCEPT_LANGUAGE"])); |
188 | | - $languages = preg_split('/[,;]/', $acceptLanguage); |
| 188 | + |
| 189 | + // take the part of the string up to the first semicolon |
| 190 | + if($semiPos = strpos( $acceptLanguage, ';' ) !== false ) |
| 191 | + $acceptLanguage = substr( $acceptLanguage, 0, $semiPos ); |
| 192 | + |
| 193 | + // explode by comma |
| 194 | + $languages = explode(',', $acceptLanguage); |
| 195 | + |
189 | 196 | foreach( $languages as $language ) { |
| 197 | + // strip whitespace |
| 198 | + $language = trim( $language ); |
190 | 199 | if( in_array( $language, $this->mVariants ) ) { |
191 | 200 | return $language; |
192 | 201 | break; |