Index: trunk/phase3/includes/OutputPage.php |
— | — | @@ -85,7 +85,14 @@ |
86 | 86 | array_push( $this->mMetatags, array( $name, $val ) ); |
87 | 87 | } |
88 | 88 | |
89 | | - function addKeyword( $text ) { array_push( $this->mKeywords, $text ); } |
| 89 | + function addKeyword( $text ) { |
| 90 | + if( is_array( $text )) { |
| 91 | + $this->mKeywords = array_merge( $this->mKeywords, $text ); |
| 92 | + } |
| 93 | + else { |
| 94 | + array_push( $this->mKeywords, $text ); |
| 95 | + } |
| 96 | + } |
90 | 97 | function addScript( $script ) { $this->mScripts .= "\t\t".$script; } |
91 | 98 | |
92 | 99 | function addExtensionStyle( $url ) { |
— | — | @@ -1479,13 +1486,22 @@ |
1480 | 1487 | } |
1481 | 1488 | |
1482 | 1489 | /** |
1483 | | - * This function takes the title (first item of mGoodLinks), categories, existing and broken links for the page |
| 1490 | + * This function takes the title (first item of mGoodLinks), categories, |
| 1491 | + * existing and broken links for the page |
1484 | 1492 | * and uses the first 10 of them for META keywords |
1485 | 1493 | * |
1486 | 1494 | * @param ParserOutput &$parserOutput |
1487 | 1495 | */ |
1488 | 1496 | private function addKeywords( &$parserOutput ) { |
1489 | | - $this->addKeyword( $this->getTitle()->getPrefixedText() ); |
| 1497 | + global $wgContLang; |
| 1498 | + // Get an array of keywords if there are more than one |
| 1499 | + // variant of the site language |
| 1500 | + $text = $wgContLang->autoConvertToAllVariants( $this->getTitle()->getPrefixedText()); |
| 1501 | + // array_values: We needn't to merge variant's code name |
| 1502 | + // into $this->mKeywords; |
| 1503 | + // array_unique: We should insert a keyword just for once |
| 1504 | + $text = array_unique( array_values( $text )); |
| 1505 | + $this->addKeyword( $text ); |
1490 | 1506 | $count = 1; |
1491 | 1507 | $links2d =& $parserOutput->getLinks(); |
1492 | 1508 | if ( !is_array( $links2d ) ) { |
— | — | @@ -1493,6 +1509,8 @@ |
1494 | 1510 | } |
1495 | 1511 | foreach ( $links2d as $dbkeys ) { |
1496 | 1512 | foreach( $dbkeys as $dbkey => $unused ) { |
| 1513 | + $dbkey = $wgContLang->autoConvertToAllVariants( $dbkey ); |
| 1514 | + $dbkey = array_unique( array_values( $dbkey )); |
1497 | 1515 | $this->addKeyword( $dbkey ); |
1498 | 1516 | if ( ++$count > 10 ) { |
1499 | 1517 | break 2; |
Index: trunk/phase3/languages/LanguageConverter.php |
— | — | @@ -183,7 +183,7 @@ |
184 | 184 | // variable in case this is called before the user's |
185 | 185 | // preference is loaded |
186 | 186 | if( array_key_exists( 'HTTP_ACCEPT_LANGUAGE', $_SERVER ) ) { |
187 | | - $acceptLanguage = str_replace( '_', '-', strtolower($_SERVER["HTTP_ACCEPT_LANGUAGE"])); |
| 187 | + $acceptLanguage = strtolower( $_SERVER['HTTP_ACCEPT_LANGUAGE'] ); |
188 | 188 | |
189 | 189 | // explode by comma |
190 | 190 | $result = explode(',', $acceptLanguage); |
Index: trunk/phase3/languages/Language.php |
— | — | @@ -35,6 +35,7 @@ |
36 | 36 | class FakeConverter { |
37 | 37 | var $mLang; |
38 | 38 | function FakeConverter($langobj) {$this->mLang = $langobj;} |
| 39 | + function autoConvertToAllVariants($text) {return $text;} |
39 | 40 | function convert($t, $i) {return $t;} |
40 | 41 | function parserConvert($t, $p) {return $t;} |
41 | 42 | function getVariants() { return array( $this->mLang->getCode() ); } |
— | — | @@ -2243,6 +2244,11 @@ |
2244 | 2245 | return $text; |
2245 | 2246 | } |
2246 | 2247 | |
| 2248 | + # convert text to all supported variants |
| 2249 | + function autoConvertToAllVariants($text) { |
| 2250 | + return $this->mConverter->autoConvertToAllVariants($text); |
| 2251 | + } |
| 2252 | + |
2247 | 2253 | # convert text to different variants of a language. |
2248 | 2254 | function convert( $text, $isTitle = false) { |
2249 | 2255 | return $this->mConverter->convert($text, $isTitle); |