Index: trunk/phase3/languages/LanguageConverter.php |
— | — | @@ -185,13 +185,22 @@ |
186 | 186 | if( array_key_exists( 'HTTP_ACCEPT_LANGUAGE', $_SERVER ) ) { |
187 | 187 | $acceptLanguage = str_replace( '_', '-', strtolower($_SERVER["HTTP_ACCEPT_LANGUAGE"])); |
188 | 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 | 189 | // explode by comma |
194 | | - $languages = explode(',', $acceptLanguage); |
| 190 | + $result = explode(',', $acceptLanguage); |
| 191 | + |
| 192 | + $languages = array(); |
195 | 193 | |
| 194 | + foreach( $result as $elem ) { |
| 195 | + // if $elem likes 'zh-cn;q=0.9' |
| 196 | + if(($posi = strpos( $elem, ';' )) !== false ) { |
| 197 | + // get the real language code likes 'zh-cn' |
| 198 | + $languages[] = substr( $elem, 0, $posi ); |
| 199 | + } |
| 200 | + else { |
| 201 | + $languages[] = $elem; |
| 202 | + } |
| 203 | + } |
| 204 | + |
196 | 205 | foreach( $languages as $language ) { |
197 | 206 | // strip whitespace |
198 | 207 | $language = trim( $language ); |