Index: trunk/phase3/RELEASE-NOTES-1.19 |
— | — | @@ -59,6 +59,8 @@ |
60 | 60 | * Conversion script between Tifinagh and Latin for the Tachelhit language |
61 | 61 | * (bug 16755) Add options 'noreplace' and 'noerror' to {{DEFAULTSORT:...}} |
62 | 62 | to stop it from replace an already existing default sort, and suppress error. |
| 63 | +* (bug 30364) LanguageConverter now depends on the page content language |
| 64 | + instead of the wiki content language |
63 | 65 | |
64 | 66 | === Bug fixes in 1.19 === |
65 | 67 | * $wgUploadNavigationUrl should be used for file redlinks if |
Index: trunk/phase3/includes/Article.php |
— | — | @@ -1050,13 +1050,14 @@ |
1051 | 1051 | * @return string containing HMTL with redirect link |
1052 | 1052 | */ |
1053 | 1053 | public function viewRedirect( $target, $appendSubtitle = true, $forceKnown = false ) { |
1054 | | - global $wgOut, $wgLang, $wgStylePath; |
| 1054 | + global $wgOut, $wgStylePath; |
1055 | 1055 | |
1056 | 1056 | if ( !is_array( $target ) ) { |
1057 | 1057 | $target = array( $target ); |
1058 | 1058 | } |
1059 | 1059 | |
1060 | | - $imageDir = $wgLang->getDir(); |
| 1060 | + $lang = $this->getTitle()->getPageLanguage(); |
| 1061 | + $imageDir = $lang->getDir(); |
1061 | 1062 | |
1062 | 1063 | if ( $appendSubtitle ) { |
1063 | 1064 | $wgOut->appendSubtitle( wfMsgHtml( 'redirectpagesub' ) ); |
— | — | @@ -1072,7 +1073,7 @@ |
1073 | 1074 | } |
1074 | 1075 | |
1075 | 1076 | $nextRedirect = $wgStylePath . '/common/images/nextredirect' . $imageDir . '.png'; |
1076 | | - $alt = $wgLang->isRTL() ? '←' : '→'; |
| 1077 | + $alt = $lang->isRTL() ? '←' : '→'; |
1077 | 1078 | // Automatically append redirect=no to each link, since most of them are redirect pages themselves. |
1078 | 1079 | foreach ( $target as $rt ) { |
1079 | 1080 | $link .= Html::element( 'img', array( 'src' => $nextRedirect, 'alt' => $alt ) ); |
Index: trunk/phase3/includes/parser/Parser.php |
— | — | @@ -321,7 +321,7 @@ |
322 | 322 | * to internalParse() which does all the real work. |
323 | 323 | */ |
324 | 324 | |
325 | | - global $wgUseTidy, $wgAlwaysUseTidy, $wgContLang, $wgDisableLangConversion, $wgDisableTitleConversion; |
| 325 | + global $wgUseTidy, $wgAlwaysUseTidy, $wgDisableLangConversion, $wgDisableTitleConversion; |
326 | 326 | $fname = __METHOD__.'-' . wfGetCaller(); |
327 | 327 | wfProfileIn( __METHOD__ ); |
328 | 328 | wfProfileIn( $fname ); |
— | — | @@ -376,8 +376,7 @@ |
377 | 377 | # The position of the convert() call should not be changed. it |
378 | 378 | # assumes that the links are all replaced and the only thing left |
379 | 379 | # is the <nowiki> mark. |
380 | | - |
381 | | - $text = $wgContLang->convert( $text ); |
| 380 | + $text = $this->getFunctionLang()->convert( $text ); |
382 | 381 | } |
383 | 382 | |
384 | 383 | /** |
— | — | @@ -393,11 +392,11 @@ |
394 | 393 | || isset( $this->mDoubleUnderscores['notitleconvert'] ) |
395 | 394 | || $this->mOutput->getDisplayTitle() !== false ) ) |
396 | 395 | { |
397 | | - $convruletitle = $wgContLang->getConvRuleTitle(); |
| 396 | + $convruletitle = $this->getFunctionLang()->getConvRuleTitle(); |
398 | 397 | if ( $convruletitle ) { |
399 | 398 | $this->mOutput->setTitleText( $convruletitle ); |
400 | 399 | } else { |
401 | | - $titleText = $wgContLang->convertTitle( $title ); |
| 400 | + $titleText = $this->getFunctionLang()->convertTitle( $title ); |
402 | 401 | $this->mOutput->setTitleText( $titleText ); |
403 | 402 | } |
404 | 403 | } |
— | — | @@ -1309,7 +1308,6 @@ |
1310 | 1309 | * @private |
1311 | 1310 | */ |
1312 | 1311 | function makeFreeExternalLink( $url ) { |
1313 | | - global $wgContLang; |
1314 | 1312 | wfProfileIn( __METHOD__ ); |
1315 | 1313 | |
1316 | 1314 | $trail = ''; |
— | — | @@ -1342,7 +1340,7 @@ |
1343 | 1341 | $text = $this->maybeMakeExternalImage( $url ); |
1344 | 1342 | if ( $text === false ) { |
1345 | 1343 | # Not an image, make a link |
1346 | | - $text = Linker::makeExternalLink( $url, $wgContLang->markNoConversion($url), true, 'free', |
| 1344 | + $text = Linker::makeExternalLink( $url, $this->getFunctionLang()->markNoConversion($url), true, 'free', |
1347 | 1345 | $this->getExternalLinkAttribs( $url ) ); |
1348 | 1346 | # Register it in the output object... |
1349 | 1347 | # Replace unnecessary URL escape codes with their equivalent characters |
— | — | @@ -1570,7 +1568,6 @@ |
1571 | 1569 | * @return string |
1572 | 1570 | */ |
1573 | 1571 | function replaceExternalLinks( $text ) { |
1574 | | - global $wgContLang; |
1575 | 1572 | wfProfileIn( __METHOD__ ); |
1576 | 1573 | |
1577 | 1574 | $bits = preg_split( $this->mExtLinkBracketedRegex, $text, -1, PREG_SPLIT_DELIM_CAPTURE ); |
— | — | @@ -1616,7 +1613,7 @@ |
1617 | 1614 | list( $dtrail, $trail ) = Linker::splitTrail( $trail ); |
1618 | 1615 | } |
1619 | 1616 | |
1620 | | - $text = $wgContLang->markNoConversion( $text ); |
| 1617 | + $text = $this->getFunctionLang()->markNoConversion( $text ); |
1621 | 1618 | |
1622 | 1619 | $url = Sanitizer::cleanUrl( $url ); |
1623 | 1620 | |
— | — | @@ -1773,8 +1770,6 @@ |
1774 | 1771 | * @private |
1775 | 1772 | */ |
1776 | 1773 | function replaceInternalLinks2( &$s ) { |
1777 | | - global $wgContLang; |
1778 | | - |
1779 | 1774 | wfProfileIn( __METHOD__ ); |
1780 | 1775 | |
1781 | 1776 | wfProfileIn( __METHOD__.'-setup' ); |
— | — | @@ -1798,7 +1793,7 @@ |
1799 | 1794 | $line = $a->current(); # Workaround for broken ArrayIterator::next() that returns "void" |
1800 | 1795 | $s = substr( $s, 1 ); |
1801 | 1796 | |
1802 | | - $useLinkPrefixExtension = $wgContLang->linkPrefixExtension(); |
| 1797 | + $useLinkPrefixExtension = $this->getFunctionLang()->linkPrefixExtension(); |
1803 | 1798 | $e2 = null; |
1804 | 1799 | if ( $useLinkPrefixExtension ) { |
1805 | 1800 | # Match the end of a line for a word that's not followed by whitespace, |
— | — | @@ -1824,8 +1819,8 @@ |
1825 | 1820 | $prefix = ''; |
1826 | 1821 | } |
1827 | 1822 | |
1828 | | - if ( $wgContLang->hasVariants() ) { |
1829 | | - $selflink = $wgContLang->autoConvertToAllVariants( $this->mTitle->getPrefixedText() ); |
| 1823 | + if ( $this->getFunctionLang()->hasVariants() ) { |
| 1824 | + $selflink = $this->getFunctionLang()->autoConvertToAllVariants( $this->mTitle->getPrefixedText() ); |
1830 | 1825 | } else { |
1831 | 1826 | $selflink = array( $this->mTitle->getPrefixedText() ); |
1832 | 1827 | } |
— | — | @@ -1993,6 +1988,7 @@ |
1994 | 1989 | |
1995 | 1990 | # Link not escaped by : , create the various objects |
1996 | 1991 | if ( $noforce ) { |
| 1992 | + global $wgContLang; |
1997 | 1993 | |
1998 | 1994 | # Interwikis |
1999 | 1995 | wfProfileIn( __METHOD__."-interwiki" ); |
— | — | @@ -2042,7 +2038,7 @@ |
2043 | 2039 | } |
2044 | 2040 | $sortkey = Sanitizer::decodeCharReferences( $sortkey ); |
2045 | 2041 | $sortkey = str_replace( "\n", '', $sortkey ); |
2046 | | - $sortkey = $wgContLang->convertCategoryKey( $sortkey ); |
| 2042 | + $sortkey = $this->getFunctionLang()->convertCategoryKey( $sortkey ); |
2047 | 2043 | $this->mOutput->addCategory( $nt->getDBkey(), $sortkey ); |
2048 | 2044 | |
2049 | 2045 | /** |
— | — | @@ -3244,7 +3240,7 @@ |
3245 | 3241 | $function = $this->mFunctionSynonyms[1][$function]; |
3246 | 3242 | } else { |
3247 | 3243 | # Case insensitive functions |
3248 | | - $function = $wgContLang->lc( $function ); |
| 3244 | + $function = $this->getFunctionLang()->lc( $function ); |
3249 | 3245 | if ( isset( $this->mFunctionSynonyms[0][$function] ) ) { |
3250 | 3246 | $function = $this->mFunctionSynonyms[0][$function]; |
3251 | 3247 | } else { |
— | — | @@ -3320,8 +3316,8 @@ |
3321 | 3317 | } |
3322 | 3318 | $titleText = $title->getPrefixedText(); |
3323 | 3319 | # Check for language variants if the template is not found |
3324 | | - if ( $wgContLang->hasVariants() && $title->getArticleID() == 0 ) { |
3325 | | - $wgContLang->findVariantLink( $part1, $title, true ); |
| 3320 | + if ( $this->getFunctionLang()->hasVariants() && $title->getArticleID() == 0 ) { |
| 3321 | + $this->getFunctionLang()->findVariantLink( $part1, $title, true ); |
3326 | 3322 | } |
3327 | 3323 | # Do recursion depth check |
3328 | 3324 | $limit = $this->mOptions->getMaxTemplateDepth(); |
Index: trunk/phase3/includes/parser/ParserOptions.php |
— | — | @@ -274,10 +274,12 @@ |
275 | 275 | * settings. |
276 | 276 | * |
277 | 277 | * @since 1.17 |
| 278 | + * @param $forOptions Array |
| 279 | + * @param $title Title: used to get the content language of the page |
278 | 280 | * @return \string Page rendering hash |
279 | 281 | */ |
280 | | - public function optionsHash( $forOptions ) { |
281 | | - global $wgContLang, $wgRenderHashAppend; |
| 282 | + public function optionsHash( $forOptions, $title = null ) { |
| 283 | + global $wgRenderHashAppend, $wgTitle; |
282 | 284 | |
283 | 285 | $confstr = ''; |
284 | 286 | |
— | — | @@ -321,7 +323,12 @@ |
322 | 324 | |
323 | 325 | // add in language specific options, if any |
324 | 326 | // @todo FIXME: This is just a way of retrieving the url/user preferred variant |
325 | | - $confstr .= $wgContLang->getExtraHashOptions(); |
| 327 | + if( !is_null( $title ) ) { |
| 328 | + $confstr .= $title->getPageLanguage()->getExtraHashOptions(); |
| 329 | + } else { |
| 330 | + global $wgContLang; |
| 331 | + $confstr .= $wgContLang->getExtraHashOptions(); |
| 332 | + } |
326 | 333 | |
327 | 334 | $confstr .= $wgRenderHashAppend; |
328 | 335 | |
Index: trunk/phase3/includes/parser/ParserCache.php |
— | — | @@ -80,7 +80,7 @@ |
81 | 81 | */ |
82 | 82 | function getETag( $article, $popts ) { |
83 | 83 | return 'W/"' . $this->getParserOutputKey( $article, |
84 | | - $popts->optionsHash( ParserOptions::legacyOptions() ) ) . |
| 84 | + $popts->optionsHash( ParserOptions::legacyOptions(), $article->getTitle() ) ) . |
85 | 85 | "--" . $article->getTouched() . '"'; |
86 | 86 | } |
87 | 87 | |
— | — | @@ -130,7 +130,7 @@ |
131 | 131 | $usedOptions = ParserOptions::legacyOptions(); |
132 | 132 | } |
133 | 133 | |
134 | | - return $this->getParserOutputKey( $article, $popts->optionsHash( $usedOptions ) ); |
| 134 | + return $this->getParserOutputKey( $article, $popts->optionsHash( $usedOptions, $article->getTitle() ) ); |
135 | 135 | } |
136 | 136 | |
137 | 137 | /** |
— | — | @@ -165,7 +165,8 @@ |
166 | 166 | $value = $this->mMemc->get( $parserOutputKey ); |
167 | 167 | if ( self::try116cache && !$value && strpos( $value, '*' ) !== -1 ) { |
168 | 168 | wfDebug( "New format parser cache miss.\n" ); |
169 | | - $parserOutputKey = $this->getParserOutputKey( $article, $popts->optionsHash( ParserOptions::legacyOptions() ) ); |
| 169 | + $parserOutputKey = $this->getParserOutputKey( $article, |
| 170 | + $popts->optionsHash( ParserOptions::legacyOptions(), $article->getTitle() ) ); |
170 | 171 | $value = $this->mMemc->get( $parserOutputKey ); |
171 | 172 | } |
172 | 173 | if ( !$value ) { |
— | — | @@ -211,7 +212,7 @@ |
212 | 213 | $optionsKey->setContainsOldMagic( $parserOutput->containsOldMagic() ); |
213 | 214 | |
214 | 215 | $parserOutputKey = $this->getParserOutputKey( $article, |
215 | | - $popts->optionsHash( $optionsKey->mUsedOptions ) ); |
| 216 | + $popts->optionsHash( $optionsKey->mUsedOptions, $article->getTitle() ) ); |
216 | 217 | |
217 | 218 | // Save the timestamp so that we don't have to load the revision row on view |
218 | 219 | $parserOutput->mTimestamp = $article->getTimestamp(); |
Index: trunk/phase3/includes/OutputPage.php |
— | — | @@ -1653,12 +1653,12 @@ |
1654 | 1654 | * /w/index.php?title=Main_page&variant=zh-cn should never be served. |
1655 | 1655 | */ |
1656 | 1656 | function addAcceptLanguage() { |
1657 | | - global $wgContLang; |
1658 | | - if( !$this->getRequest()->getCheck( 'variant' ) && $wgContLang->hasVariants() ) { |
1659 | | - $variants = $wgContLang->getVariants(); |
| 1657 | + $lang = $this->getTitle()->getPageLanguage(); |
| 1658 | + if( !$this->getRequest()->getCheck( 'variant' ) && $lang->hasVariants() ) { |
| 1659 | + $variants = $lang->getVariants(); |
1660 | 1660 | $aloption = array(); |
1661 | 1661 | foreach ( $variants as $variant ) { |
1662 | | - if( $variant === $wgContLang->getCode() ) { |
| 1662 | + if( $variant === $lang->getCode() ) { |
1663 | 1663 | continue; |
1664 | 1664 | } else { |
1665 | 1665 | $aloption[] = 'string-contains=' . $variant; |
— | — | @@ -2613,7 +2613,7 @@ |
2614 | 2614 | * have to be purged on configuration changes. |
2615 | 2615 | */ |
2616 | 2616 | protected function getJSVars() { |
2617 | | - global $wgUseAjax, $wgEnableMWSuggest, $wgContLang; |
| 2617 | + global $wgUseAjax, $wgEnableMWSuggest; |
2618 | 2618 | |
2619 | 2619 | $title = $this->getTitle(); |
2620 | 2620 | $ns = $title->getNamespace(); |
— | — | @@ -2639,8 +2639,9 @@ |
2640 | 2640 | 'wgCategories' => $this->getCategories(), |
2641 | 2641 | 'wgBreakFrames' => $this->getFrameOptions() == 'DENY', |
2642 | 2642 | ); |
2643 | | - if ( $wgContLang->hasVariants() ) { |
2644 | | - $vars['wgUserVariant'] = $wgContLang->getPreferredVariant(); |
| 2643 | + $lang = $this->getTitle()->getPageLanguage(); |
| 2644 | + if ( $lang->hasVariants() ) { |
| 2645 | + $vars['wgUserVariant'] = $lang->getPreferredVariant(); |
2645 | 2646 | } |
2646 | 2647 | foreach ( $title->getRestrictionTypes() as $type ) { |
2647 | 2648 | $vars['wgRestriction' . ucfirst( $type )] = $title->getRestrictions( $type ); |
— | — | @@ -2692,7 +2693,7 @@ |
2693 | 2694 | global $wgUniversalEditButton, $wgFavicon, $wgAppleTouchIcon, $wgEnableAPI, |
2694 | 2695 | $wgSitename, $wgVersion, $wgHtml5, $wgMimeType, |
2695 | 2696 | $wgFeed, $wgOverrideSiteFeed, $wgAdvertisedFeedTypes, |
2696 | | - $wgDisableLangConversion, $wgCanonicalLanguageLinks, $wgContLang, |
| 2697 | + $wgDisableLangConversion, $wgCanonicalLanguageLinks, |
2697 | 2698 | $wgRightsPage, $wgRightsUrl; |
2698 | 2699 | |
2699 | 2700 | $tags = array(); |
— | — | @@ -2818,14 +2819,16 @@ |
2819 | 2820 | ) ); |
2820 | 2821 | } |
2821 | 2822 | |
| 2823 | + $lang = $this->getTitle()->getPageLanguage(); |
| 2824 | + |
2822 | 2825 | # Language variants |
2823 | 2826 | if ( !$wgDisableLangConversion && $wgCanonicalLanguageLinks |
2824 | | - && $wgContLang->hasVariants() ) { |
| 2827 | + && $lang->hasVariants() ) { |
2825 | 2828 | |
2826 | | - $urlvar = $wgContLang->getURLVariant(); |
| 2829 | + $urlvar = $lang->getURLVariant(); |
2827 | 2830 | |
2828 | 2831 | if ( !$urlvar ) { |
2829 | | - $variants = $wgContLang->getVariants(); |
| 2832 | + $variants = $lang->getVariants(); |
2830 | 2833 | foreach ( $variants as $_v ) { |
2831 | 2834 | $tags[] = Html::element( 'link', array( |
2832 | 2835 | 'rel' => 'alternate', |
Index: trunk/phase3/includes/Title.php |
— | — | @@ -877,7 +877,7 @@ |
878 | 878 | */ |
879 | 879 | public function getLocalURL( $query = '', $variant = false ) { |
880 | 880 | global $wgArticlePath, $wgScript, $wgServer, $wgRequest; |
881 | | - global $wgVariantArticlePath, $wgContLang; |
| 881 | + global $wgVariantArticlePath; |
882 | 882 | |
883 | 883 | if ( is_array( $query ) ) { |
884 | 884 | $query = wfArrayToCGI( $query ); |
— | — | @@ -896,7 +896,7 @@ |
897 | 897 | } else { |
898 | 898 | $dbkey = wfUrlencode( $this->getPrefixedDBkey() ); |
899 | 899 | if ( $query == '' ) { |
900 | | - if ( $variant != false && $wgContLang->hasVariants() ) { |
| 900 | + if ( $variant != false && $this->getPageLanguage()->hasVariants() ) { |
901 | 901 | if ( !$wgVariantArticlePath ) { |
902 | 902 | $variantArticlePath = "$wgScript?title=$1&variant=$2"; // default |
903 | 903 | } else { |
— | — | @@ -4369,9 +4369,6 @@ |
4370 | 4370 | if ( $this->getNamespace() == NS_SPECIAL ) { |
4371 | 4371 | // special pages are in the user language |
4372 | 4372 | return $wgLang; |
4373 | | - } elseif ( $this->isRedirect() ) { |
4374 | | - // the arrow on a redirect page is aligned according to the user language |
4375 | | - return $wgLang; |
4376 | 4373 | } elseif ( $this->isCssOrJsPage() ) { |
4377 | 4374 | // css/js should always be LTR and is, in fact, English |
4378 | 4375 | return wfGetLangObj( 'en' ); |
Index: trunk/phase3/includes/SkinLegacy.php |
— | — | @@ -279,13 +279,14 @@ |
280 | 280 | $s = ''; |
281 | 281 | |
282 | 282 | /* show links to different language variants */ |
283 | | - global $wgDisableLangConversion, $wgLang, $wgContLang; |
| 283 | + global $wgDisableLangConversion, $wgLang; |
284 | 284 | |
285 | | - $variants = $wgContLang->getVariants(); |
| 285 | + $lang = $this->getSkin()->getTitle()->getPageLanguage(); |
| 286 | + $variants = $lang->getVariants(); |
286 | 287 | |
287 | 288 | if ( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) { |
288 | 289 | foreach ( $variants as $code ) { |
289 | | - $varname = $wgContLang->getVariantname( $code ); |
| 290 | + $varname = $lang->getVariantname( $code ); |
290 | 291 | |
291 | 292 | if ( $varname == 'disable' ) { |
292 | 293 | continue; |
Index: trunk/phase3/includes/SkinTemplate.php |
— | — | @@ -1012,16 +1012,21 @@ |
1013 | 1013 | array( &$this, &$content_navigation ) ); |
1014 | 1014 | } |
1015 | 1015 | |
| 1016 | + $pageLang = $title->getPageLanguage(); |
| 1017 | + |
1016 | 1018 | // Gets list of language variants |
1017 | | - $variants = $wgContLang->getVariants(); |
| 1019 | + $variants = $pageLang->getVariants(); |
1018 | 1020 | // Checks that language conversion is enabled and variants exist |
1019 | | - if( !$wgDisableLangConversion && count( $variants ) > 1 ) { |
1020 | | - // Gets preferred variant |
1021 | | - $preferred = $wgContLang->getPreferredVariant(); |
| 1021 | + // And if it is not in the special namespace |
| 1022 | + if( !$wgDisableLangConversion && count( $variants ) > 1 |
| 1023 | + && $title->getNamespace() != NS_SPECIAL ) { |
| 1024 | + // Gets preferred variant (note that user preference is |
| 1025 | + // only possible for wiki content language variant) |
| 1026 | + $preferred = $pageLang->getPreferredVariant(); |
1022 | 1027 | // Loops over each variant |
1023 | 1028 | foreach( $variants as $code ) { |
1024 | 1029 | // Gets variant name from language code |
1025 | | - $varname = $wgContLang->getVariantname( $code ); |
| 1030 | + $varname = $pageLang->getVariantname( $code ); |
1026 | 1031 | // Checks if the variant is marked as disabled |
1027 | 1032 | if( $varname == 'disable' ) { |
1028 | 1033 | // Skips this variant |
Index: trunk/phase3/includes/WikiPage.php |
— | — | @@ -2559,7 +2559,7 @@ |
2560 | 2560 | * @return mixed ParserOptions object or boolean false |
2561 | 2561 | */ |
2562 | 2562 | public function getParserOptions( $canonical = false ) { |
2563 | | - global $wgUser, $wgLanguageCode; |
| 2563 | + global $wgUser; |
2564 | 2564 | |
2565 | 2565 | if ( !$this->mParserOptions || $canonical ) { |
2566 | 2566 | $user = !$canonical ? $wgUser : new User; |
— | — | @@ -2568,7 +2568,7 @@ |
2569 | 2569 | $parserOptions->enableLimitReport(); |
2570 | 2570 | |
2571 | 2571 | if ( $canonical ) { |
2572 | | - $parserOptions->setUserLang( $wgLanguageCode ); # Must be set explicitely |
| 2572 | + $parserOptions->setUserLang( $this->mTitle->getPageLanguage() ); # Must be set explicitely |
2573 | 2573 | return $parserOptions; |
2574 | 2574 | } |
2575 | 2575 | $this->mParserOptions = $parserOptions; |
Index: trunk/phase3/languages/LanguageConverter.php |
— | — | @@ -158,7 +158,7 @@ |
159 | 159 | // not memoized (i.e. there return value is not cached) since |
160 | 160 | // new information might appear during processing after this |
161 | 161 | // is first called. |
162 | | - if ( $req ) { |
| 162 | + if ( $req = $this->validateVariant( $req ) ) { |
163 | 163 | return $req; |
164 | 164 | } |
165 | 165 | return $this->mMainLanguageCode; |