Jdlrobson has uploaded a new change for review.
https://gerrit.wikimedia.org/r/155670
Change subject: i18n the time messages
......................................................................
i18n the time messages
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, 96 insertions(+), 21 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow
refs/changes/70/155670/1
diff --git a/Resources.php b/Resources.php
index 1eeefe9..8328d7c 100644
--- a/Resources.php
+++ b/Resources.php
@@ -261,6 +261,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 23eca5a..13394e0 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -13,6 +13,11 @@
"echo-pref-tooltip-flow-discussion": "Notify me when actions related to me
occur in Flow.",
"flow": "Flow",
"flow-active-ago": "Active $1",
+ "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-add-topic": "Add Topic ",
"flow-anon-warning": "You are not logged in. To receive attribution with
your name instead of your IP address, you can [$1 log in] or [$2 create an
account].",
"flow-anonymous": "Anonymous",
@@ -48,6 +53,11 @@
"flow-edit-title-submit": "Change title",
"flow-edit-title-submit-overwrite": "Overwrite title",
"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-embedding-unsupported": "Discussions cannot be embedded yet.",
"flow-error-close-moderated-post": "You cannot close a moderated post.",
"flow-error-default": "An error has occurred.",
@@ -283,6 +293,11 @@
"flow-special-type-workflow": "Workflow",
"flow-special-uuid": "UUID",
"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-stub-post-content": "''Due to a technical error, this post could not
be retrieved.''",
"flow-summarize-topic-placeholder": "Please summarize this discussion",
"flow-summarize-topic-submit": "Summarize",
@@ -301,6 +316,11 @@
"flow-terms-of-use-reply": "By clicking \"{{int:flow-reply-submit}}\", you
agree to the terms of use for this wiki.",
"flow-terms-of-use-summarize": "By clicking
\"{{int:flow-summarize-topic-submit}}\", you agree to the terms of use for this
wiki.",
"flow-thank-link": "{{GENDER:$1|Thank}}",
+ "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",
"flow-toggle-small-topics": "Switch to small topics view",
"flow-toggle-topics": "Switch to topics only view",
"flow-toggle-topics-posts": "Switch to topics and posts view",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index d71b659..cc64e49 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -17,6 +17,11 @@
"echo-pref-tooltip-flow-discussion": "This is a short description of
the flow-discussion notification category.\n{{Related|Echo-pref-tooltip}}",
"flow": "{{doc-special|Flow}}\n{{Identical|Flow}}",
"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-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-add-topic": "Button text for submitting a new topic to the page",
"flow-anon-warning": "Warning message to be displayed when anonymous
user starts writing a new topic or reply.\n* $1 is a URL to log in.\n* $2 is a
URL to register an account.",
"flow-anonymous": "{{Identical|Anonymous}}",
@@ -52,6 +57,11 @@
"flow-edit-title-submit": "Used as label for the Submit button.",
"flow-edit-title-submit-overwrite": "Used as label for the Submit
button, when submitting will overwrite a more recent change.",
"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-embedding-unsupported": "Error message displayed if a user tries
to transclude a Flow page.",
"flow-error-close-moderated-post": "Used as error message when user
attempts to close a moderated topic/post.",
"flow-error-default": "General error message for flow.",
@@ -287,6 +297,11 @@
"flow-special-type-workflow": "Label for Workflow in the type
dropdown.\n{{Identical|Workflow}}",
"flow-special-uuid": "Label for the UUID field on the redirector
special page.\n\nUUID is unique identifier for the revisioned object containing
the reference.",
"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-stub-post-content": "Stub post content to be displayed when the
real post could not be loaded due to technical issues.",
"flow-summarize-topic-placeholder": "Used as placeholder for
summarizing topic textarea.",
"flow-summarize-topic-submit": "Used as label for the Summarize
button.\n\nAlso used in:\n* {{msg-mw|Flow-terms-of-use-summarize}}\n*
{{msg-mw|Wikimedia-flow-terms-of-use-summarize}}\n{{Identical|Summarize}}",
@@ -305,6 +320,11 @@
"flow-terms-of-use-reply": "Terms of use for posting a reply.\n\nRefers
to {{msg-mw|Flow-reply-submit}}.\n{{Related|Flow-terms-of-use}}",
"flow-terms-of-use-summarize": "Terms of use for summarizing a
header/topic/post.\n\nRefers to
{{msg-mw|Flow-summarize-topic-submit}}.\n{{Related|Flow-terms-of-use}}",
"flow-thank-link": "Link text of the button that will (when clicked)
thank the editor of the comment Parameters:\n* $1 - username, can be used for
GENDER\n{{Identical|Thank}}",
+ "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.",
"flow-toggle-small-topics": "Tooltip displayed when mouse hovering over
the full page topic collapser. When clicked only topic titles are displayed.",
"flow-toggle-topics": "Tooltip displayed when mouse hovering over the
full page topic collapser. When clicked posts are not displayed, only topic
titles and metadata are visible.",
"flow-toggle-topics-posts": "Tooltip displayed when mouse hovering over
the full page topic collapser. When clicked posts will be displayed with topic
titles.",
diff --git a/modules/new/flow-handlebars.js b/modules/new/flow-handlebars.js
index 7553c18..cd80f90 100644
--- a/modules/new/flow-handlebars.js
+++ b/modules/new/flow-handlebars.js
@@ -193,31 +193,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: newchange
Gerrit-Change-Id: I87fcc5184b4c30e7d52173ea665d803e1b202811
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits