Index: trunk/phase3/RELEASE-NOTES-1.19 |
— | — | @@ -61,6 +61,8 @@ |
62 | 62 | to stop it from replace an already existing default sort, and suppress error. |
63 | 63 | * (bug 18578) Rewrote revision delete related messages to allow better |
64 | 64 | localisation |
| 65 | +* (bug 30364) LanguageConverter now depends on the page content language |
| 66 | + instead of the wiki content language |
65 | 67 | |
66 | 68 | === Bug fixes in 1.19 === |
67 | 69 | * $wgUploadNavigationUrl should be used for file redlinks if |
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 | } |
— | — | @@ -1194,7 +1193,6 @@ |
1195 | 1194 | * @private |
1196 | 1195 | */ |
1197 | 1196 | function makeFreeExternalLink( $url ) { |
1198 | | - global $wgContLang; |
1199 | 1197 | wfProfileIn( __METHOD__ ); |
1200 | 1198 | |
1201 | 1199 | $trail = ''; |
— | — | @@ -1227,7 +1225,7 @@ |
1228 | 1226 | $text = $this->maybeMakeExternalImage( $url ); |
1229 | 1227 | if ( $text === false ) { |
1230 | 1228 | # Not an image, make a link |
1231 | | - $text = Linker::makeExternalLink( $url, $wgContLang->markNoConversion($url), true, 'free', |
| 1229 | + $text = Linker::makeExternalLink( $url, $this->getFunctionLang()->markNoConversion($url), true, 'free', |
1232 | 1230 | $this->getExternalLinkAttribs( $url ) ); |
1233 | 1231 | # Register it in the output object... |
1234 | 1232 | # Replace unnecessary URL escape codes with their equivalent characters |
— | — | @@ -1455,7 +1453,6 @@ |
1456 | 1454 | * @return string |
1457 | 1455 | */ |
1458 | 1456 | function replaceExternalLinks( $text ) { |
1459 | | - global $wgContLang; |
1460 | 1457 | wfProfileIn( __METHOD__ ); |
1461 | 1458 | |
1462 | 1459 | $bits = preg_split( $this->mExtLinkBracketedRegex, $text, -1, PREG_SPLIT_DELIM_CAPTURE ); |
— | — | @@ -1501,7 +1498,7 @@ |
1502 | 1499 | list( $dtrail, $trail ) = Linker::splitTrail( $trail ); |
1503 | 1500 | } |
1504 | 1501 | |
1505 | | - $text = $wgContLang->markNoConversion( $text ); |
| 1502 | + $text = $this->getFunctionLang()->markNoConversion( $text ); |
1506 | 1503 | |
1507 | 1504 | $url = Sanitizer::cleanUrl( $url ); |
1508 | 1505 | |
— | — | @@ -1658,8 +1655,6 @@ |
1659 | 1656 | * @private |
1660 | 1657 | */ |
1661 | 1658 | function replaceInternalLinks2( &$s ) { |
1662 | | - global $wgContLang; |
1663 | | - |
1664 | 1659 | wfProfileIn( __METHOD__ ); |
1665 | 1660 | |
1666 | 1661 | wfProfileIn( __METHOD__.'-setup' ); |
— | — | @@ -1683,7 +1678,7 @@ |
1684 | 1679 | $line = $a->current(); # Workaround for broken ArrayIterator::next() that returns "void" |
1685 | 1680 | $s = substr( $s, 1 ); |
1686 | 1681 | |
1687 | | - $useLinkPrefixExtension = $wgContLang->linkPrefixExtension(); |
| 1682 | + $useLinkPrefixExtension = $this->getFunctionLang()->linkPrefixExtension(); |
1688 | 1683 | $e2 = null; |
1689 | 1684 | if ( $useLinkPrefixExtension ) { |
1690 | 1685 | # Match the end of a line for a word that's not followed by whitespace, |
— | — | @@ -1709,8 +1704,8 @@ |
1710 | 1705 | $prefix = ''; |
1711 | 1706 | } |
1712 | 1707 | |
1713 | | - if ( $wgContLang->hasVariants() ) { |
1714 | | - $selflink = $wgContLang->autoConvertToAllVariants( $this->mTitle->getPrefixedText() ); |
| 1708 | + if ( $this->getFunctionLang()->hasVariants() ) { |
| 1709 | + $selflink = $this->getFunctionLang()->autoConvertToAllVariants( $this->mTitle->getPrefixedText() ); |
1715 | 1710 | } else { |
1716 | 1711 | $selflink = array( $this->mTitle->getPrefixedText() ); |
1717 | 1712 | } |
— | — | @@ -1878,6 +1873,7 @@ |
1879 | 1874 | |
1880 | 1875 | # Link not escaped by : , create the various objects |
1881 | 1876 | if ( $noforce ) { |
| 1877 | + global $wgContLang; |
1882 | 1878 | |
1883 | 1879 | # Interwikis |
1884 | 1880 | wfProfileIn( __METHOD__."-interwiki" ); |
— | — | @@ -1927,7 +1923,7 @@ |
1928 | 1924 | } |
1929 | 1925 | $sortkey = Sanitizer::decodeCharReferences( $sortkey ); |
1930 | 1926 | $sortkey = str_replace( "\n", '', $sortkey ); |
1931 | | - $sortkey = $wgContLang->convertCategoryKey( $sortkey ); |
| 1927 | + $sortkey = $this->getFunctionLang()->convertCategoryKey( $sortkey ); |
1932 | 1928 | $this->mOutput->addCategory( $nt->getDBkey(), $sortkey ); |
1933 | 1929 | |
1934 | 1930 | /** |
— | — | @@ -3028,7 +3024,7 @@ |
3029 | 3025 | * @private |
3030 | 3026 | */ |
3031 | 3027 | function braceSubstitution( $piece, $frame ) { |
3032 | | - global $wgContLang, $wgNonincludableNamespaces, $wgEnableInterwikiTranscluding, $wgEnableInterwikiTemplatesTracking; |
| 3028 | + global $wgNonincludableNamespaces, $wgEnableInterwikiTranscluding, $wgEnableInterwikiTemplatesTracking; |
3033 | 3029 | wfProfileIn( __METHOD__ ); |
3034 | 3030 | wfProfileIn( __METHOD__.'-setup' ); |
3035 | 3031 | |
— | — | @@ -3129,7 +3125,7 @@ |
3130 | 3126 | $function = $this->mFunctionSynonyms[1][$function]; |
3131 | 3127 | } else { |
3132 | 3128 | # Case insensitive functions |
3133 | | - $function = $wgContLang->lc( $function ); |
| 3129 | + $function = $this->getFunctionLang()->lc( $function ); |
3134 | 3130 | if ( isset( $this->mFunctionSynonyms[0][$function] ) ) { |
3135 | 3131 | $function = $this->mFunctionSynonyms[0][$function]; |
3136 | 3132 | } else { |
— | — | @@ -3205,8 +3201,8 @@ |
3206 | 3202 | } |
3207 | 3203 | $titleText = $title->getPrefixedText(); |
3208 | 3204 | # Check for language variants if the template is not found |
3209 | | - if ( $wgContLang->hasVariants() && $title->getArticleID() == 0 ) { |
3210 | | - $wgContLang->findVariantLink( $part1, $title, true ); |
| 3205 | + if ( $this->getFunctionLang()->hasVariants() && $title->getArticleID() == 0 ) { |
| 3206 | + $this->getFunctionLang()->findVariantLink( $part1, $title, true ); |
3211 | 3207 | } |
3212 | 3208 | # Do recursion depth check |
3213 | 3209 | $limit = $this->mOptions->getMaxTemplateDepth(); |
Index: trunk/phase3/includes/parser/ParserOptions.php |
— | — | @@ -275,11 +275,11 @@ |
276 | 276 | * |
277 | 277 | * @since 1.17 |
278 | 278 | * @param $forOptions Array |
279 | | - * @param $title Title: will be used to get the page content language (since r97636) |
| 279 | + * @param $title Title: used to get the content language of the page (since r97636) |
280 | 280 | * @return \string Page rendering hash |
281 | 281 | */ |
282 | 282 | public function optionsHash( $forOptions, $title = null ) { |
283 | | - global $wgContLang, $wgRenderHashAppend; |
| 283 | + global $wgRenderHashAppend; |
284 | 284 | |
285 | 285 | $confstr = ''; |
286 | 286 | |
— | — | @@ -323,7 +323,12 @@ |
324 | 324 | |
325 | 325 | // add in language specific options, if any |
326 | 326 | // @todo FIXME: This is just a way of retrieving the url/user preferred variant |
327 | | - $confstr .= $wgContLang->getExtraHashOptions(); |
| 327 | + if( !is_null( $title ) ) { |
| 328 | + $confstr .= $title->getPageLanguage()->getExtraHashOptions(); |
| 329 | + } else { |
| 330 | + global $wgContLang; |
| 331 | + $confstr .= $wgContLang->getExtraHashOptions(); |
| 332 | + } |
328 | 333 | |
329 | 334 | $confstr .= $wgRenderHashAppend; |
330 | 335 | |
Index: trunk/phase3/includes/OutputPage.php |
— | — | @@ -1654,12 +1654,12 @@ |
1655 | 1655 | * /w/index.php?title=Main_page&variant=zh-cn should never be served. |
1656 | 1656 | */ |
1657 | 1657 | function addAcceptLanguage() { |
1658 | | - global $wgContLang; |
1659 | | - if( !$this->getRequest()->getCheck( 'variant' ) && $wgContLang->hasVariants() ) { |
1660 | | - $variants = $wgContLang->getVariants(); |
| 1658 | + $lang = $this->getTitle()->getPageLanguage(); |
| 1659 | + if( !$this->getRequest()->getCheck( 'variant' ) && $lang->hasVariants() ) { |
| 1660 | + $variants = $lang->getVariants(); |
1661 | 1661 | $aloption = array(); |
1662 | 1662 | foreach ( $variants as $variant ) { |
1663 | | - if( $variant === $wgContLang->getCode() ) { |
| 1663 | + if( $variant === $lang->getCode() ) { |
1664 | 1664 | continue; |
1665 | 1665 | } else { |
1666 | 1666 | $aloption[] = 'string-contains=' . $variant; |
— | — | @@ -2614,7 +2614,7 @@ |
2615 | 2615 | * have to be purged on configuration changes. |
2616 | 2616 | */ |
2617 | 2617 | protected function getJSVars() { |
2618 | | - global $wgUseAjax, $wgEnableMWSuggest, $wgContLang; |
| 2618 | + global $wgUseAjax, $wgEnableMWSuggest; |
2619 | 2619 | |
2620 | 2620 | $title = $this->getTitle(); |
2621 | 2621 | $ns = $title->getNamespace(); |
— | — | @@ -2640,9 +2640,10 @@ |
2641 | 2641 | 'wgCategories' => $this->getCategories(), |
2642 | 2642 | 'wgBreakFrames' => $this->getFrameOptions() == 'DENY', |
2643 | 2643 | ); |
2644 | | - if ( $wgContLang->hasVariants() ) { |
2645 | | - $vars['wgUserVariant'] = $wgContLang->getPreferredVariant(); |
2646 | | - } |
| 2644 | + $lang = $this->getTitle()->getPageLanguage(); |
| 2645 | + if ( $lang->hasVariants() ) { |
| 2646 | + $vars['wgUserVariant'] = $lang->getPreferredVariant(); |
| 2647 | + } |
2647 | 2648 | foreach ( $title->getRestrictionTypes() as $type ) { |
2648 | 2649 | $vars['wgRestriction' . ucfirst( $type )] = $title->getRestrictions( $type ); |
2649 | 2650 | } |
— | — | @@ -2693,7 +2694,7 @@ |
2694 | 2695 | global $wgUniversalEditButton, $wgFavicon, $wgAppleTouchIcon, $wgEnableAPI, |
2695 | 2696 | $wgSitename, $wgVersion, $wgHtml5, $wgMimeType, |
2696 | 2697 | $wgFeed, $wgOverrideSiteFeed, $wgAdvertisedFeedTypes, |
2697 | | - $wgDisableLangConversion, $wgCanonicalLanguageLinks, $wgContLang, |
| 2698 | + $wgDisableLangConversion, $wgCanonicalLanguageLinks, |
2698 | 2699 | $wgRightsPage, $wgRightsUrl; |
2699 | 2700 | |
2700 | 2701 | $tags = array(); |
— | — | @@ -2819,14 +2820,16 @@ |
2820 | 2821 | ) ); |
2821 | 2822 | } |
2822 | 2823 | |
| 2824 | + $lang = $this->getTitle()->getPageLanguage(); |
| 2825 | + |
2823 | 2826 | # Language variants |
2824 | 2827 | if ( !$wgDisableLangConversion && $wgCanonicalLanguageLinks |
2825 | | - && $wgContLang->hasVariants() ) { |
| 2828 | + && $lang->hasVariants() ) { |
2826 | 2829 | |
2827 | | - $urlvar = $wgContLang->getURLVariant(); |
| 2830 | + $urlvar = $lang->getURLVariant(); |
2828 | 2831 | |
2829 | 2832 | if ( !$urlvar ) { |
2830 | | - $variants = $wgContLang->getVariants(); |
| 2833 | + $variants = $lang->getVariants(); |
2831 | 2834 | foreach ( $variants as $_v ) { |
2832 | 2835 | $tags[] = Html::element( 'link', array( |
2833 | 2836 | 'rel' => 'alternate', |
Index: trunk/phase3/includes/Title.php |
— | — | @@ -885,7 +885,7 @@ |
886 | 886 | */ |
887 | 887 | public function getLocalURL( $query = '', $variant = false ) { |
888 | 888 | global $wgArticlePath, $wgScript, $wgServer, $wgRequest; |
889 | | - global $wgVariantArticlePath, $wgContLang; |
| 889 | + global $wgVariantArticlePath; |
890 | 890 | |
891 | 891 | if ( is_array( $query ) ) { |
892 | 892 | $query = wfArrayToCGI( $query ); |
— | — | @@ -904,7 +904,7 @@ |
905 | 905 | } else { |
906 | 906 | $dbkey = wfUrlencode( $this->getPrefixedDBkey() ); |
907 | 907 | if ( $query == '' ) { |
908 | | - if ( $variant != false && $wgContLang->hasVariants() ) { |
| 908 | + if ( $variant != false && $this->getPageLanguage()->hasVariants() ) { |
909 | 909 | if ( !$wgVariantArticlePath ) { |
910 | 910 | $variantArticlePath = "$wgScript?title=$1&variant=$2"; // default |
911 | 911 | } else { |
Index: trunk/phase3/includes/SkinLegacy.php |
— | — | @@ -269,13 +269,15 @@ |
270 | 270 | $s = ''; |
271 | 271 | |
272 | 272 | /* show links to different language variants */ |
273 | | - global $wgDisableLangConversion, $wgLang, $wgContLang; |
| 273 | + global $wgDisableLangConversion, $wgLang; |
274 | 274 | |
275 | | - $variants = $wgContLang->getVariants(); |
| 275 | + $lang = $this->getSkin()->getTitle()->getPageLanguage(); |
| 276 | + $variants = $lang->getVariants(); |
276 | 277 | |
277 | | - if ( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) { |
| 278 | + if ( !$wgDisableLangConversion && sizeof( $variants ) > 1 |
| 279 | + && $title->getNamespace() != NS_SPECIAL ) { |
278 | 280 | foreach ( $variants as $code ) { |
279 | | - $varname = $wgContLang->getVariantname( $code ); |
| 281 | + $varname = $lang->getVariantname( $code ); |
280 | 282 | |
281 | 283 | if ( $varname == 'disable' ) { |
282 | 284 | continue; |
Index: trunk/phase3/includes/SkinTemplate.php |
— | — | @@ -1011,16 +1011,21 @@ |
1012 | 1012 | array( &$this, &$content_navigation ) ); |
1013 | 1013 | } |
1014 | 1014 | |
| 1015 | + $pageLang = $title->getPageLanguage(); |
| 1016 | + |
1015 | 1017 | // Gets list of language variants |
1016 | | - $variants = $wgContLang->getVariants(); |
| 1018 | + $variants = $pageLang->getVariants(); |
1017 | 1019 | // Checks that language conversion is enabled and variants exist |
1018 | | - if( !$wgDisableLangConversion && count( $variants ) > 1 ) { |
1019 | | - // Gets preferred variant |
1020 | | - $preferred = $wgContLang->getPreferredVariant(); |
| 1020 | + // And if it is not in the special namespace |
| 1021 | + if( !$wgDisableLangConversion && count( $variants ) > 1 |
| 1022 | + && $title->getNamespace() != NS_SPECIAL ) { |
| 1023 | + // Gets preferred variant (note that user preference is |
| 1024 | + // only possible for wiki content language variant) |
| 1025 | + $preferred = $pageLang->getPreferredVariant(); |
1021 | 1026 | // Loops over each variant |
1022 | 1027 | foreach( $variants as $code ) { |
1023 | 1028 | // Gets variant name from language code |
1024 | | - $varname = $wgContLang->getVariantname( $code ); |
| 1029 | + $varname = $pageLang->getVariantname( $code ); |
1025 | 1030 | // Checks if the variant is marked as disabled |
1026 | 1031 | if( $varname == 'disable' ) { |
1027 | 1032 | // Skips this variant |