jenkins-bot has submitted this change and it was merged.
Change subject: i18n the time messages
......................................................................
i18n the time messages
Note the PHP template helpers go untouched, as since HTML
is cached we don't want to vary the output every second.
They should simply output the exact timestamp.
Change-Id: I87fcc5184b4c30e7d52173ea665d803e1b202811
---
M Resources.php
M i18n/en.json
M i18n/qqq.json
M modules/new/flow-handlebars.js
M tests/qunit/new/test_flow-handlebars.js
5 files changed, 98 insertions(+), 23 deletions(-)
Approvals:
SG: Looks good to me, approved
Siebrand: Looks good to me, but someone else must approve
Matthias Mullie: Looks good to me, but someone else must approve
jenkins-bot: Verified
diff --git a/Resources.php b/Resources.php
index b372fe7..256dda1 100644
--- a/Resources.php
+++ b/Resources.php
@@ -260,6 +260,28 @@
'scripts' => array(
'new/flow-handlebars.js',
),
+ 'messages' => array(
+ 'flow-time-ago-second',
+ 'flow-time-ago-minute',
+ 'flow-time-ago-hour',
+ 'flow-time-ago-day',
+ 'flow-time-ago-week',
+ 'flow-active-ago-second',
+ 'flow-active-ago-minute',
+ 'flow-active-ago-hour',
+ 'flow-active-ago-day',
+ 'flow-active-ago-week',
+ 'flow-started-ago-second',
+ 'flow-started-ago-minute',
+ 'flow-started-ago-hour',
+ 'flow-started-ago-day',
+ 'flow-started-ago-week',
+ 'flow-edited-ago-second',
+ 'flow-edited-ago-minute',
+ 'flow-edited-ago-hour',
+ 'flow-edited-ago-day',
+ 'flow-edited-ago-week',
+ ),
'dependencies' => array(
'ext.mantle.handlebars',
),
diff --git a/i18n/en.json b/i18n/en.json
index 79287dc..2448345 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -326,7 +326,17 @@
"flow-topic-comment-count": "$1 {{PLURAL:$1|comment|comments}}",
"flow-active-ago": "Active $1",
"flow-started-ago": "Started $1",
+ "flow-started-ago-day": "Started $1 {{PLURAL:$1|day|days}} ago",
+ "flow-started-ago-hour": "Started $1 {{PLURAL:$1|hour|hours}} ago",
+ "flow-started-ago-minute": "Started $1 {{PLURAL:$1|minute|minutes}} ago",
+ "flow-started-ago-second": "Started $1 {{PLURAL:$1|second|seconds}} ago",
+ "flow-started-ago-week": "Started $1 {{PLURAL:$1|week|weeks}} ago",
"flow-edited-ago": "Edited $1",
+ "flow-edited-ago-day": "Edited $1 {{PLURAL:$1|day|days}} ago",
+ "flow-edited-ago-hour": "Edited $1 {{PLURAL:$1|hour|hours}} ago",
+ "flow-edited-ago-minute": "Edited $1 {{PLURAL:$1|minute|minutes}} ago",
+ "flow-edited-ago-second": "Edited $1 {{PLURAL:$1|second|seconds}} ago",
+ "flow-edited-ago-week": "Edited $1 {{PLURAL:$1|week|weeks}} ago",
"flow-load-more": "Load More",
"flow-no-more-fwd": "There are no older topics",
"flow-add-topic": "Add Topic ",
@@ -353,5 +363,15 @@
"flow-preview-return-edit-post": "Keep editing",
"flow-anonymous": "Anonymous",
"flow-embedding-unsupported": "Discussions cannot be embedded yet.",
- "mw-ui-unsubmitted-confirm": "You have unsubmitted changes on this page.
Are you sure you want to navigate away and lose your work?"
+ "mw-ui-unsubmitted-confirm": "You have unsubmitted changes on this page.
Are you sure you want to navigate away and lose your work?",
+ "flow-active-ago-day": "Active $1 {{PLURAL:$1|day|days}} ago",
+ "flow-active-ago-hour": "Active $1 {{PLURAL:$1|hour|hours}} ago",
+ "flow-active-ago-minute": "Active $1 {{PLURAL:$1|minute|minutes}} ago",
+ "flow-active-ago-second": "Active $1 {{PLURAL:$1|second|seconds}} ago",
+ "flow-active-ago-week": "Active $1 {{PLURAL:$1|week|weeks}} ago",
+ "flow-time-ago-day": "$1 {{PLURAL:$1|day|days}} ago",
+ "flow-time-ago-hour": "$1 {{PLURAL:$1|hour|hours}} ago",
+ "flow-time-ago-minute": "$1 {{PLURAL:$1|minute|minutes}} ago",
+ "flow-time-ago-second": "$1 {{PLURAL:$1|second|seconds}} ago",
+ "flow-time-ago-week": "$1 {{PLURAL:$1|week|weeks}} ago"
}
diff --git a/i18n/qqq.json b/i18n/qqq.json
index b4b8c7a..0ba6ebc 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -330,7 +330,17 @@
"flow-topic-comment-count": "Message displayed in the topic title bar
to indicate the number of replies within the topic. Parameters:\n* $1 - The
number of comments within the topic.\n{{Identical|Comment}}",
"flow-active-ago": "Message displayed in the topic title bar to
indicate how long ago the topic was last changed. Parameters:\n* $1 - Humanized
time ago from CLDR. ex: 17 hours ago\n{{Identical|Active}}",
"flow-started-ago": "Message displayed in the topic title bar to
indicate how long ago the topic was created. Parameters:\n* $1 - Humanized time
ago from CLDR. ex: 17 hours ago\n{{Identical|Started}}",
+ "flow-started-ago-day": "A statement described the time passed since a
topic was started. Parameters\n * $1 - days that have passed since event.",
+ "flow-started-ago-hour": "A statement described the time passed since a
topic was started. Parameters\n * $1 - hours that have passed since event.",
+ "flow-started-ago-minute": "A statement described the time passed since
a topic was started. Parameters\n * $1 - minutes that have passed since event.",
+ "flow-started-ago-second": "A statement described the time passed since
a topic was started. Parameters\n * $1 - seconds that have passed since event.",
+ "flow-started-ago-week": "A statement described the time passed since a
topic was started. Parameters\n * $1 - weeks that have passed since event.",
"flow-edited-ago": "Message displayed below a post that has been edited
indicating how long ago it was edited. Parameters:\n* $1 - Humanized time ago
from CLDR. ex: 4 days ago\n{{Identical|Edited}}",
+ "flow-edited-ago-day": "A statement described the time passed since a
post was edited. Parameters\\n * $1 - days that have passed since event.",
+ "flow-edited-ago-hour": "A statement described the time passed since a
post was edited. Parameters\\n * $1 - hours that have passed since event.",
+ "flow-edited-ago-minute": "A statement described the time passed since
a post was edited. Parameters\\n * $1 - minutes that have passed since event.",
+ "flow-edited-ago-second": "A statement described the time passed since
a post was edited. Parameters\\n * $1 - seconds that have passed since event.",
+ "flow-edited-ago-week": "A statement described the time passed since a
post was edited. Parameters\\n * $1 - weeks that have passed since event.",
"flow-load-more": "Message displayed inside a button that fetches more
topics and appends them to the bottom of the page\n{{Identical|Load more}}",
"flow-no-more-fwd": "Displayed instead of 'flow-load-more' when there
are no more topics to show in the forward direction",
"flow-add-topic": "Button text for submitting a new topic to the page",
@@ -357,5 +367,15 @@
"flow-preview-return-edit-post": "Used as text for a button that hides
previewed text and returns to the editing view",
"flow-anonymous": "{{Identical|Anonymous}}",
"flow-embedding-unsupported": "Error message displayed if a user tries
to transclude a Flow page.",
- "mw-ui-unsubmitted-confirm": "You have unsubmitted changes on this
page. Are you sure you want to navigate away and lose your work?"
+ "mw-ui-unsubmitted-confirm": "You have unsubmitted changes on this
page. Are you sure you want to navigate away and lose your work?",
+ "flow-active-ago-day": "A statement described the time passed since a
post was active. Parameters:\\n * $1 - days that have passed since event.",
+ "flow-active-ago-hour": "A statement described the time passed since a
post was active. Parameters:\\n * $1 - hours that have passed since event.",
+ "flow-active-ago-minute": "A statement described the time passed since
a post was active. Parameters:\\n * $1 - minutes that have passed since event.",
+ "flow-active-ago-second": "A statement described the time passed since
a post was active. Parameters:\\n * $1 - seconds that have passed since event.",
+ "flow-active-ago-week": "A statement described the time passed since a
post was active. Parameters\\n * $1 - weeks that have passed since event.",
+ "flow-time-ago-day": "A statement described the time passed since an
event. Parameters\n * $1 - days that have passed since event.",
+ "flow-time-ago-hour": "A statement described the time passed since an
event. Parameters\n * $1 - hours that have passed since event.",
+ "flow-time-ago-minute": "A statement described the time passed since an
event. Parameters\n * $1 - minutes that have passed since event.",
+ "flow-time-ago-second": "A statement described the time passed since an
event. Parameters\n * $1 - seconds that have passed since event.",
+ "flow-time-ago-week": "A statement described the time passed since an
event. Parameters\n * $1 - weeks that have passed since event."
}
diff --git a/modules/new/flow-handlebars.js b/modules/new/flow-handlebars.js
index 96e6eab..7edf42d 100644
--- a/modules/new/flow-handlebars.js
+++ b/modules/new/flow-handlebars.js
@@ -185,31 +185,40 @@
return mw.message( str ).params( [ name
] );
},
- "_time": function ( seconds_ago ) {
- var str = ' second',
- new_time = seconds_ago;
+ "time": function ( msgKeyPrefix, secondsAgo ) {
+ var suffix = '-second',
+ new_time = secondsAgo;
- if ( seconds_ago >= 604800 ) {
- new_time = seconds_ago / 604800;
- str = ' week';
- } else if ( seconds_ago >= 86400 ) {
- new_time = seconds_ago / 86400;
- str = ' day';
- } else if ( seconds_ago >= 3600 ) {
- new_time = seconds_ago / 3600;
- str = ' hour';
- } else if ( seconds_ago >= 60 ) {
- new_time = seconds_ago / 60;
- str = ' minute';
+ if ( secondsAgo >= 604800 ) {
+ new_time = secondsAgo / 604800;
+ suffix = '-week';
+ } else if ( secondsAgo >= 86400 ) {
+ new_time = secondsAgo / 86400;
+ suffix = '-day';
+ } else if ( secondsAgo >= 3600 ) {
+ new_time = secondsAgo / 3600;
+ suffix = '-hour';
+ } else if ( secondsAgo >= 60 ) {
+ new_time = secondsAgo / 60;
+ suffix = '-minute';
}
- return Math.floor( new_time ) + str + (
new_time < 1 || new_time >= 2 ? 's' : '' );
+ return mw.msg.call( this, msgKeyPrefix
+ suffix, Math.floor( new_time ) );
},
- "time_ago": function ( seconds_ago ) { return
this._time( seconds_ago ) + " ago"; },
- "active_ago": function ( seconds_ago ) { return
"Active " + this.time_ago( seconds_ago ); },
- "started_ago": function ( seconds_ago ) {
return "Started " + this.time_ago( seconds_ago ); },
- "edited_ago": function ( seconds_ago ) { return
"Edited " + this.time_ago( seconds_ago ); },
+ // FIXME: Kill the above 4 in favour of the
generic time helper parameter
+ "time_ago": function ( secondsAgo ) {
+ return this.time( 'flow-time-ago',
secondsAgo );
+ },
+ "active_ago": function ( secondsAgo ) {
+ return this.time( 'flow-active-ago',
secondsAgo );
+ },
+ "started_ago": function ( secondsAgo ) {
+ return this.time( 'flow-started-ago',
secondsAgo );
+ },
+ "edited_ago": function ( secondsAgo ) {
+ return this.time( 'flow-edited-ago',
secondsAgo );
+ },
"datetime": function ( timestamp ) {
return ( new Date( timestamp )
).toLocaleString();
diff --git a/tests/qunit/new/test_flow-handlebars.js
b/tests/qunit/new/test_flow-handlebars.js
index b09ac8d..62b2d90 100644
--- a/tests/qunit/new/test_flow-handlebars.js
+++ b/tests/qunit/new/test_flow-handlebars.js
@@ -151,7 +151,7 @@
);
} );
-QUnit.test( 'FlowHandlebars.prototype.l10n', 8, function( assert ) {
+QUnit.test( 'FlowHandlebars.prototype.l10n', 11, function( assert ) {
assert.strictEqual( this.handlebarsProto.l10n( 'time_ago', 2 ), '2
seconds ago', 'Check seconds.' );
assert.strictEqual( this.handlebarsProto.l10n( 'time_ago', 120 ), '2
minutes ago', 'Check minutes.' );
assert.strictEqual( this.handlebarsProto.l10n( 'time_ago', 60 * 60 * 2
), '2 hours ago', 'Check hour.' );
@@ -160,6 +160,10 @@
assert.strictEqual( this.handlebarsProto.l10n( 'active_ago', 60 * 60 *
24 * 7 * 2 ), 'Active 2 weeks ago', 'Check week.' );
assert.strictEqual( this.handlebarsProto.l10n( 'started_ago', 60 * 60 *
24 * 7 * 2 ), 'Started 2 weeks ago', 'Check week.' );
assert.strictEqual( this.handlebarsProto.l10n( 'edited_ago', 60 * 60 *
24 * 7 * 2 ), 'Edited 2 weeks ago', 'Check week.' );
+
+ assert.strictEqual( this.handlebarsProto.l10n( 'active_ago', 1 ),
'Active 1 second ago', 'Check non-plural.' );
+ assert.strictEqual( this.handlebarsProto.l10n( 'started_ago', 60 * 60 *
24 * 7 * 1 ), 'Started 1 week ago', 'Check non-plural' );
+ assert.strictEqual( this.handlebarsProto.l10n( 'edited_ago', 60 * 60 *
24 * 1 ), 'Edited 1 day ago', 'Check non-plural' );
} );
} ( jQuery ) );
--
To view, visit https://gerrit.wikimedia.org/r/155670
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I87fcc5184b4c30e7d52173ea665d803e1b202811
Gerrit-PatchSet: 9
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>
Gerrit-Reviewer: Bsitu <[email protected]>
Gerrit-Reviewer: Jdlrobson <[email protected]>
Gerrit-Reviewer: Matthias Mullie <[email protected]>
Gerrit-Reviewer: SG <[email protected]>
Gerrit-Reviewer: Siebrand <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits