r87818 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r87817‎ | r87818 | r87819 >
Date:13:46, 10 May 2011
Author:faurethomas
Status:deferred
Tags:
Comment:
Simplify WikiTweetFunctions::Convert_Date using native Language::formatTimePeriod . fix r87811
Modified paths:
  • /trunk/extensions/WikiTweet/WikiTweet.functions.php (modified) (history)
  • /trunk/extensions/WikiTweet/WikiTweet.i18n.php (modified) (history)

Diff [purge]

Index: trunk/extensions/WikiTweet/WikiTweet.i18n.php
@@ -29,14 +29,8 @@
3030 'wikitweet-anonymous' => 'anonymous',
3131 'wikitweet-tweets-tagged' => 'Tweets tagged',
3232 'wikitweet-back-timeline' => 'Back to the timeline',
33 - 'wikitweet-tweets-from-room' => 'Tweets from room',
 33+ 'wikitweet-tweets-from-room' => 'Tweets from room',
3434 'wikitweet-timeago' => '$1 ago',
35 - 'wikitweet-hour' => 'hour',
36 - 'wikitweet-hours' => 'hours',
37 - 'wikitweet-minute' => 'minute',
38 - 'wikitweet-minutes' => 'minutes',
39 - 'wikitweet-second' => 'second',
40 - 'wikitweet-seconds' => 'seconds',
4135 'wikitweet-inthefuture' => 'In the future !!',
4236 'wikitweet-fewsecondsago' => 'Few seconds ago'
4337 );
@@ -102,12 +96,6 @@
10397 'wikitweet-back-timeline' => 'Retour au flux',
10498 'wikitweet-tweets-from-room' => 'Tweets de la room',
10599 'wikitweet-timeago' => 'Il y a $1',
106 - 'wikitweet-hour' => 'heure',
107 - 'wikitweet-hours' => 'heures',
108 - 'wikitweet-minute' => 'minute',
109 - 'wikitweet-minutes' => 'minutes',
110 - 'wikitweet-second' => 'seconde',
111 - 'wikitweet-seconds' => 'secondes',
112100 'wikitweet-inthefuture' => 'Dans le futur !!',
113101 'wikitweet-fewsecondsago' => 'Il y a quelques secondes'
114102 );
Index: trunk/extensions/WikiTweet/WikiTweet.functions.php
@@ -88,49 +88,12 @@
8989 // less than 10 seconds is "few"
9090 $result = wfMsg ( 'wikitweet-fewsecondsago' ) ;
9191 }
92 - elseif ( $l__diff_date >= 60 )
93 - {
94 - // real conversion
95 - $l__nber_seconds = $l__diff_date % 60 ;
96 - $l__new_diff = $l__diff_date - $l__nber_seconds ;
97 - $l__nber_minutes = $l__new_diff / 60 ;
98 - if ($l__nber_minutes >= 60)
99 - {
100 - $l__old_nber_minutes = $l__nber_minutes ;
101 - $l__nber_minutes = $l__nber_minutes % 60 ;
102 - $l__new_nber_minutes = $l__old_nber_minutes - $l__nber_minutes ;
103 - $l__nber_hours = $l__new_nber_minutes / 60 ;
104 - }
105 - }
10692 else
10793 {
108 - $l__nber_seconds = $l__diff_date ;
 94+ $languageobject = new Language();
 95+ $date_to_display = $languageobject->formatTimePeriod(time()-strtotime($dateSrc));
 96+ $result = wfMsgExt( 'wikitweet-timeago', 'parse', $date_to_display );
10997 }
110 - //plurals
111 - $seconds = ( $l__nber_seconds == 1 ) ? wfMsg( 'wikitweet-second' ) : wfMsg( 'wikitweet-seconds' ) ;
112 - $minutes = ( $l__nber_minutes == 1 ) ? wfMsg( 'wikitweet-minute' ) : wfMsg( 'wikitweet-minutes' ) ;
113 - $hours = ( $l__nber_hours == 1 ) ? wfMsg( 'wikitweet-hour' ) : wfMsg( 'wikitweet-hours' ) ;
114 -
115 - if ($l__nber_hours !=0 && $l__nber_minutes != 0 )
116 - {
117 - $result = wfMsgExt( 'wikitweet-timeago', 'parse', "$l__nber_hours $hours $l__nber_minutes $minutes" );
118 - }
119 - elseif (($l__nber_hours != 0 && $l__nber_minutes == 0 ) || ($l__nber_hours >= 5 ) )
120 - {
121 - $result = wfMsgExt( 'wikitweet-timeago', 'parse', "$l__nber_hours $hours" );
122 - }
123 - elseif (($l__nber_minutes >= 5) || ($l__nber_minutes != 0 && $l__nber_seconds == 0 ) )
124 - {
125 - $result = wfMsgExt( 'wikitweet-timeago', 'parse', "$l__nber_minutes $minutes" );
126 - }
127 - elseif ($l__nber_minutes != 0 && $l__nber_seconds != 0 )
128 - {
129 - $result = wfMsgExt( 'wikitweet-timeago', 'parse', "$l__nber_minutes $minutes $l__nber_seconds $seconds" );
130 - }
131 - elseif ($l__nber_seconds !=0 )
132 - {
133 - $result = wfMsgExt( 'wikitweet-timeago', 'parse', "$l__nber_seconds $seconds" );
134 - }
13598 return $result ;
13699 }
137100 }

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r87811Add a function to convert a tweet timestamp in a countdown. Include the func...faurethomas08:56, 10 May 2011

Status & tagging log