r94680 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r94679‎ | r94680 | r94681 >
Date:19:29, 16 August 2011
Author:robin
Status:resolved (Comments)
Tags:
Comment:
Magic words (time and number-formatting ones, plus DIRECTIONMARK, but not NAMESPACE) now depend on the page content language instead of the site language. In theory this sets the right magic words in system messages, although they are not used there.
Useful for multilingual wikis like Incubator, and probably for extensions like Translate.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES-1.19 (modified) (history)
  • /trunk/phase3/includes/parser/Parser.php (modified) (history)

Diff [purge]

Index: trunk/phase3/RELEASE-NOTES-1.19
@@ -36,6 +36,9 @@
3737 * Most presentational html attributes like valign are now converted to inline
3838 css style rules. These attributes were removed from html5 and so we clean them up
3939 when $wgHtml5 is enabled. This can be disabled using $wgCleanupPresentationalAttributes.
 40+* Magic words (time and number-formatting ones, plus DIRECTIONMARK, but not NAMESPACE)
 41+ now depend on the page content language instead of the site language. In theory
 42+ this sets the right magic words in system messages, although they are not used there.
4043
4144 === Bug fixes in 1.19 ===
4245 * $wgUploadNavigationUrl should be used for file redlinks if
Index: trunk/phase3/includes/parser/Parser.php
@@ -2694,48 +2694,50 @@
26952695 date_default_timezone_set( $oldtz );
26962696 }
26972697
 2698+ $pageLang = $this->getFunctionLang();
 2699+
26982700 switch ( $index ) {
26992701 case 'currentmonth':
2700 - $value = $wgContLang->formatNum( gmdate( 'm', $ts ) );
 2702+ $value = $pageLang->formatNum( gmdate( 'm', $ts ) );
27012703 break;
27022704 case 'currentmonth1':
2703 - $value = $wgContLang->formatNum( gmdate( 'n', $ts ) );
 2705+ $value = $pageLang->formatNum( gmdate( 'n', $ts ) );
27042706 break;
27052707 case 'currentmonthname':
2706 - $value = $wgContLang->getMonthName( gmdate( 'n', $ts ) );
 2708+ $value = $pageLang->getMonthName( gmdate( 'n', $ts ) );
27072709 break;
27082710 case 'currentmonthnamegen':
2709 - $value = $wgContLang->getMonthNameGen( gmdate( 'n', $ts ) );
 2711+ $value = $pageLang->getMonthNameGen( gmdate( 'n', $ts ) );
27102712 break;
27112713 case 'currentmonthabbrev':
2712 - $value = $wgContLang->getMonthAbbreviation( gmdate( 'n', $ts ) );
 2714+ $value = $pageLang->getMonthAbbreviation( gmdate( 'n', $ts ) );
27132715 break;
27142716 case 'currentday':
2715 - $value = $wgContLang->formatNum( gmdate( 'j', $ts ) );
 2717+ $value = $pageLang->formatNum( gmdate( 'j', $ts ) );
27162718 break;
27172719 case 'currentday2':
2718 - $value = $wgContLang->formatNum( gmdate( 'd', $ts ) );
 2720+ $value = $pageLang->formatNum( gmdate( 'd', $ts ) );
27192721 break;
27202722 case 'localmonth':
2721 - $value = $wgContLang->formatNum( $localMonth );
 2723+ $value = $pageLang->formatNum( $localMonth );
27222724 break;
27232725 case 'localmonth1':
2724 - $value = $wgContLang->formatNum( $localMonth1 );
 2726+ $value = $pageLang->formatNum( $localMonth1 );
27252727 break;
27262728 case 'localmonthname':
2727 - $value = $wgContLang->getMonthName( $localMonthName );
 2729+ $value = $pageLang->getMonthName( $localMonthName );
27282730 break;
27292731 case 'localmonthnamegen':
2730 - $value = $wgContLang->getMonthNameGen( $localMonthName );
 2732+ $value = $pageLang->getMonthNameGen( $localMonthName );
27312733 break;
27322734 case 'localmonthabbrev':
2733 - $value = $wgContLang->getMonthAbbreviation( $localMonthName );
 2735+ $value = $pageLang->getMonthAbbreviation( $localMonthName );
27342736 break;
27352737 case 'localday':
2736 - $value = $wgContLang->formatNum( $localDay );
 2738+ $value = $pageLang->formatNum( $localDay );
27372739 break;
27382740 case 'localday2':
2739 - $value = $wgContLang->formatNum( $localDay2 );
 2741+ $value = $pageLang->formatNum( $localDay2 );
27402742 break;
27412743 case 'pagename':
27422744 $value = wfEscapeWikiText( $this->mTitle->getText() );
@@ -2860,68 +2862,68 @@
28612863 $value = ( wfUrlencode( $this->mTitle->getSubjectNsText() ) );
28622864 break;
28632865 case 'currentdayname':
2864 - $value = $wgContLang->getWeekdayName( gmdate( 'w', $ts ) + 1 );
 2866+ $value = $pageLang->getWeekdayName( gmdate( 'w', $ts ) + 1 );
28652867 break;
28662868 case 'currentyear':
2867 - $value = $wgContLang->formatNum( gmdate( 'Y', $ts ), true );
 2869+ $value = $pageLang->formatNum( gmdate( 'Y', $ts ), true );
28682870 break;
28692871 case 'currenttime':
2870 - $value = $wgContLang->time( wfTimestamp( TS_MW, $ts ), false, false );
 2872+ $value = $pageLang->time( wfTimestamp( TS_MW, $ts ), false, false );
28712873 break;
28722874 case 'currenthour':
2873 - $value = $wgContLang->formatNum( gmdate( 'H', $ts ), true );
 2875+ $value = $pageLang->formatNum( gmdate( 'H', $ts ), true );
28742876 break;
28752877 case 'currentweek':
28762878 # @bug 4594 PHP5 has it zero padded, PHP4 does not, cast to
28772879 # int to remove the padding
2878 - $value = $wgContLang->formatNum( (int)gmdate( 'W', $ts ) );
 2880+ $value = $pageLang->formatNum( (int)gmdate( 'W', $ts ) );
28792881 break;
28802882 case 'currentdow':
2881 - $value = $wgContLang->formatNum( gmdate( 'w', $ts ) );
 2883+ $value = $pageLang->formatNum( gmdate( 'w', $ts ) );
28822884 break;
28832885 case 'localdayname':
2884 - $value = $wgContLang->getWeekdayName( $localDayOfWeek + 1 );
 2886+ $value = $pageLang->getWeekdayName( $localDayOfWeek + 1 );
28852887 break;
28862888 case 'localyear':
2887 - $value = $wgContLang->formatNum( $localYear, true );
 2889+ $value = $pageLang->formatNum( $localYear, true );
28882890 break;
28892891 case 'localtime':
2890 - $value = $wgContLang->time( $localTimestamp, false, false );
 2892+ $value = $pageLang->time( $localTimestamp, false, false );
28912893 break;
28922894 case 'localhour':
2893 - $value = $wgContLang->formatNum( $localHour, true );
 2895+ $value = $pageLang->formatNum( $localHour, true );
28942896 break;
28952897 case 'localweek':
28962898 # @bug 4594 PHP5 has it zero padded, PHP4 does not, cast to
28972899 # int to remove the padding
2898 - $value = $wgContLang->formatNum( (int)$localWeek );
 2900+ $value = $pageLang->formatNum( (int)$localWeek );
28992901 break;
29002902 case 'localdow':
2901 - $value = $wgContLang->formatNum( $localDayOfWeek );
 2903+ $value = $pageLang->formatNum( $localDayOfWeek );
29022904 break;
29032905 case 'numberofarticles':
2904 - $value = $wgContLang->formatNum( SiteStats::articles() );
 2906+ $value = $pageLang->formatNum( SiteStats::articles() );
29052907 break;
29062908 case 'numberoffiles':
2907 - $value = $wgContLang->formatNum( SiteStats::images() );
 2909+ $value = $pageLang->formatNum( SiteStats::images() );
29082910 break;
29092911 case 'numberofusers':
2910 - $value = $wgContLang->formatNum( SiteStats::users() );
 2912+ $value = $pageLang->formatNum( SiteStats::users() );
29112913 break;
29122914 case 'numberofactiveusers':
2913 - $value = $wgContLang->formatNum( SiteStats::activeUsers() );
 2915+ $value = $pageLang->formatNum( SiteStats::activeUsers() );
29142916 break;
29152917 case 'numberofpages':
2916 - $value = $wgContLang->formatNum( SiteStats::pages() );
 2918+ $value = $pageLang->formatNum( SiteStats::pages() );
29172919 break;
29182920 case 'numberofadmins':
2919 - $value = $wgContLang->formatNum( SiteStats::numberingroup( 'sysop' ) );
 2921+ $value = $pageLang->formatNum( SiteStats::numberingroup( 'sysop' ) );
29202922 break;
29212923 case 'numberofedits':
2922 - $value = $wgContLang->formatNum( SiteStats::edits() );
 2924+ $value = $pageLang->formatNum( SiteStats::edits() );
29232925 break;
29242926 case 'numberofviews':
2925 - $value = $wgContLang->formatNum( SiteStats::views() );
 2927+ $value = $pageLang->formatNum( SiteStats::views() );
29262928 break;
29272929 case 'currenttimestamp':
29282930 $value = wfTimestamp( TS_MW, $ts );
@@ -2948,7 +2950,7 @@
29492951 case 'stylepath':
29502952 return $wgStylePath;
29512953 case 'directionmark':
2952 - return $wgContLang->getDirMark();
 2954+ return $pageLang->getDirMark();
29532955 case 'contentlanguage':
29542956 global $wgLanguageCode;
29552957 return $wgLanguageCode;

Follow-up revisions

RevisionCommit summaryAuthorDate
r94716Follow-up r94680 - fix unit tests....bawolff00:46, 17 August 2011

Comments

#Comment by SPQRobin (talk | contribs)   19:30, 16 August 2011

See language in MediaWiki for more info.

#Comment by Bawolff (talk | contribs)   01:26, 17 August 2011

I fixed the unit test so re-setting to new (cruise control is still throwing a hissy and blaming this revision over r94714 though)

#Comment by Hashar (talk | contribs)   06:13, 17 August 2011

Thanks for fixing tests!

#Comment by Bawolff (talk | contribs)   16:27, 17 August 2011

We should probably add a new magic word for page language to go along with {{CONTENTLANGUAGE}}, for completeness.

#Comment by SPQRobin (talk | contribs)   21:01, 22 August 2011

Yeah, was thinking about it as well. However, didn't add it because I thought it would be better to add it when it is requested/needed.

Status & tagging log