diff --git a/Popups.i18n.php b/Popups.i18n.php
index 32d2080ab..07fe52ad1 100644
--- a/Popups.i18n.php
+++ b/Popups.i18n.php
@@ -27,11 +27,7 @@ $messages = array();
$messages['en'] = array(
'popups-message' => 'Popups',
'popups-desc' => 'Displays popups with summaries of page contents when the user hovers over a page link.',
- 'popups-edited-seconds' => 'Last edited {{PLURAL:$1|1 second|$1 seconds}} ago.',
- 'popups-edited-minutes' => 'Last edited {{PLURAL:$1|1 minute|$1 minutes}} ago.',
- 'popups-edited-hours' => 'Last edited {{PLURAL:$1|1 hour|$1 hours}} ago.',
- 'popups-edited-days' => 'Last edited {{PLURAL:$1|yesterday|$1 days ago}}.',
- 'popups-edited-years' => 'Last edited {{PLURAL:$1|1 year|$1 years}} ago.',
+ 'popups-last-edited' => 'Last edited $1',
'popups-redirects' => 'redirects to
$1
',
);
@@ -41,21 +37,7 @@ $messages['en'] = array(
$messages['qqq'] = array(
'popups-message' => 'Name shown in user preference for this extension',
'popups-desc' => '{{desc|name=Popups|url=https://www.mediawiki.org/wiki/Extension:Popups}}',
- 'popups-edited-seconds' => 'Message to show time span if page was edited less than a minute ago. Parameters:
-* $1 - number of seconds
-{{Related|Popups-edited}}',
- 'popups-edited-minutes' => 'Message to show time span if page was edited less than an hour ago. Parameters:
-* $1 - number of minutes
-{{Related|Popups-edited}}',
- 'popups-edited-hours' => 'Message to show time span if page was edited less than a day ago. Parameters:
-* $1 - number of hours
-{{Related|Popups-edited}}',
- 'popups-edited-days' => 'Message to show time span if page was edited less than a year ago. Parameters:
-* $1 - number of days
-{{Related|Popups-edited}}',
- 'popups-edited-years' => 'Message to show time span if page was edited more than a year ago. Parameters:
-* $1 - number of years
-{{Related|Popups-edited}}',
+ 'popups-last-edited' => 'Message to show time span since the page was last edited. $1 is the timespan in words.',
'popups-redirects' => 'Message shown when the popup is showing a redirected page',
);
diff --git a/Popups.php b/Popups.php
index 815086e4d..b23f162f5 100644
--- a/Popups.php
+++ b/Popups.php
@@ -45,13 +45,10 @@ $wgResourceModules = array_merge( $wgResourceModules, array(
'dependencies' => array(
'mediawiki.api',
'mediawiki.jqueryMsg',
+ 'moment',
),
'messages' => array(
- 'popups-edited-seconds',
- 'popups-edited-minutes',
- 'popups-edited-hours',
- 'popups-edited-days',
- 'popups-edited-years',
+ 'popups-last-edited',
'popups-redirects',
),
'remoteExtPath' => $remoteExtPath,
diff --git a/resources/ext.popups.core.js b/resources/ext.popups.core.js
index b370d8484..93b2b7b5a 100644
--- a/resources/ext.popups.core.js
+++ b/resources/ext.popups.core.js
@@ -63,7 +63,7 @@
$timestamp = $( '' )
.addClass( timestampclass )
.append(
- $( '' ).text( timeAgo( timediff ).text() )
+ $( '' ).text( mw.message( 'popups-last-edited', moment( timestamp ).fromNow() ).text() )
);
if ( redirects ) {
@@ -412,49 +412,4 @@
} );
- // Util functions that should be separated out into their own files at some point
-
- /**
- * @method timeAgo
- * Formats a given time duration (in ms) into a relative string.
- *
- * @param {number} ms The time duration to convert to a relative string, in ms
- * @return {Object} A mw.message object with the appropriate relative string.
- */
- function timeAgo( ms ) {
- var i, ts, timeSegments = [
- {
- factor: 1000,
- min: 60,
- message: 'popups-edited-seconds'
- },
- {
- factor: 60,
- min: 60,
- message: 'popups-edited-minutes'
- },
- {
- factor: 60,
- min: 24,
- message: 'popups-edited-hours'
- },
- {
- factor: 24,
- min: 365,
- message: 'popups-edited-days'
- },
- {
- factor: 365,
- message: 'popups-edited-years'
- }
- ], curDuration = ms;
-
- for ( i = 0; i <= timeSegments.length; i++ ) {
- ts = timeSegments[ i ];
- curDuration = Math.floor( curDuration / ts.factor );
- if ( typeof ts.min === 'undefined' || curDuration < ts.min ) {
- return mw.message( ts.message, curDuration );
- }
- }
- }
} ) ( jQuery );