jenkins-bot has submitted this change and it was merged. Change subject: i18n: Allow translation of participants ......................................................................
i18n: Allow translation of participants Switch to using more generic i10n function Use simpler message for plural handling - only used last author and creator to avoid having to deal with edge cases where creator and last 2 authors were the same person. Dependency: I15c167f245ba0842fc77fb4e03e380c40784ee1b Change-Id: Ia45427ddf74bb7b74c7dd5e341507b3cff065097 --- M Resources.php M handlebars/compiled/flow_block_topic.handlebars.php M handlebars/compiled/flow_block_topic_moderate_post.handlebars.php M handlebars/compiled/flow_block_topic_moderate_topic.handlebars.php M handlebars/compiled/flow_block_topiclist.handlebars.php M handlebars/flow_topic_titlebar_content.handlebars M i18n/en.json M i18n/qqq.json M includes/Formatter/TopicFormatter.php M includes/Formatter/TopicListFormatter.php M includes/TemplateHelper.php M modules/new/flow-handlebars.js 12 files changed, 32 insertions(+), 34 deletions(-) Approvals: Matthias Mullie: Looks good to me, approved jenkins-bot: Verified diff --git a/Resources.php b/Resources.php index 07dbf77..608e6e2 100644 --- a/Resources.php +++ b/Resources.php @@ -108,6 +108,7 @@ 'flow-toggle-small-topics', 'flow-toggle-topics', 'flow-toggle-topics-posts', + 'flow-topic-participants', 'flow-topic-action-hide-topic', 'flow-topic-action-close-topic', 'flow-topic-action-delete-topic', diff --git a/handlebars/compiled/flow_block_topic.handlebars.php b/handlebars/compiled/flow_block_topic.handlebars.php index 64d3ae3..5604d18 100644 --- a/handlebars/compiled/flow_block_topic.handlebars.php +++ b/handlebars/compiled/flow_block_topic.handlebars.php @@ -48,7 +48,9 @@ class="wikiglyph '.LCRun3::hbch($cx, 'ifEquals', Array(Array(((is_array($in) && isset($in['moderateState'])) ? $in['moderateState'] : null),'close'),Array()), $in, function($cx, $in) {return 'wikiglyph-stop';}).''.LCRun3::hbch($cx, 'ifEquals', Array(Array(((is_array($in) && isset($in['moderateState'])) ? $in['moderateState'] : null),'hide'),Array()), $in, function($cx, $in) {return 'wikiglyph-flag';}).''.LCRun3::hbch($cx, 'ifEquals', Array(Array(((is_array($in) && isset($in['moderateState'])) ? $in['moderateState'] : null),'delete'),Array()), $in, function($cx, $in) {return 'wikiglyph-trash';}).'"></span> '.LCRun3::ch($cx, 'l10n', Array(Array('post_moderation_state',((is_array($in) && isset($in['moderateState'])) ? $in['moderateState'] : null),((is_array($in) && isset($in['replyToId'])) ? $in['replyToId'] : null),((is_array($in['moderator']) && isset($in['moderator']['name'])) ? $in['moderator']['name'] : null)),Array()), 'encq').'</div> ' : '').' -<span class="flow-author">'.LCRun3::ch($cx, 'l10n', Array(Array('started_with_participants',$in),Array()), 'encq').'</span> +<span class="flow-author"> + '.LCRun3::ch($cx, 'l10n', Array(Array('flow-topic-participants',((is_array($in) && isset($in['author_count'])) ? $in['author_count'] : null),((is_array($in) && isset($in['unnamed_author_count'])) ? $in['unnamed_author_count'] : null),((is_array($in['creator']) && isset($in['creator']['name'])) ? $in['creator']['name'] : null),((is_array($in) && isset($in['last_author_name'])) ? $in['last_author_name'] : null)),Array()), 'encq').' +</span> <div class="flow-topic-meta"> '.((LCRun3::ifvar($cx, ((is_array($in['actions']) && isset($in['actions']['reply'])) ? $in['actions']['reply'] : null))) ? ' <a href="#flow-post-'.htmlentities(((is_array($in) && isset($in['postId'])) ? $in['postId'] : null), ENT_QUOTES, 'UTF-8').'-form-content" @@ -61,9 +63,9 @@ '.LCRun3::ch($cx, 'l10n', Array(Array('flow-topic-comments',((is_array($in) && isset($in['reply_count'])) ? $in['reply_count'] : null)),Array()), 'encq').' • '.((LCRun3::ifvar($cx, ((is_array($in) && isset($in['last_updated'])) ? $in['last_updated'] : null))) ? ' - <!--span class="wikiglyph wikiglyph-speech-bubbles"></span--> '.LCRun3::ch($cx, 'timestamp', Array(Array(((is_array($in) && isset($in['last_updated'])) ? $in['last_updated'] : null),'active_ago'),Array()), 'encq').' + <!--span class="wikiglyph wikiglyph-speech-bubbles"></span--> '.LCRun3::ch($cx, 'timestamp', Array(Array(((is_array($in) && isset($in['last_updated'])) ? $in['last_updated'] : null),'flow-active-ago'),Array()), 'encq').' ' : ' - <!--span class="wikiglyph wikiglyph-speech-bubble"></span--> '.LCRun3::ch($cx, 'uuidTimestamp', Array(Array(((is_array($in) && isset($in['postId'])) ? $in['postId'] : null),'started_ago'),Array()), 'encq').' + <!--span class="wikiglyph wikiglyph-speech-bubble"></span--> '.LCRun3::ch($cx, 'uuidTimestamp', Array(Array(((is_array($in) && isset($in['postId'])) ? $in['postId'] : null),'flow-started-ago'),Array()), 'encq').' ').' </div> <span class="flow-reply-count"><span class="wikiglyph wikiglyph-speech-bubble"></span><span class="flow-reply-count-number">'.htmlentities(((is_array($in) && isset($in['reply_count'])) ? $in['reply_count'] : null), ENT_QUOTES, 'UTF-8').'</span></span> diff --git a/handlebars/compiled/flow_block_topic_moderate_post.handlebars.php b/handlebars/compiled/flow_block_topic_moderate_post.handlebars.php index 8274f4d..0c5818b 100644 --- a/handlebars/compiled/flow_block_topic_moderate_post.handlebars.php +++ b/handlebars/compiled/flow_block_topic_moderate_post.handlebars.php @@ -151,13 +151,13 @@ class="mw-ui-progressive mw-ui-quiet" title="'.htmlentities(((is_array($in['links']['diff-prev']) && isset($in['links']['diff-prev']['title'])) ? $in['links']['diff-prev']['title'] : null), ENT_QUOTES, 'UTF-8').'"> ' : '').' - '.LCRun3::ch($cx, 'uuidTimestamp', Array(Array(((is_array($in) && isset($in['revisionId'])) ? $in['revisionId'] : null),'edited_ago'),Array()), 'encq').' + '.LCRun3::ch($cx, 'uuidTimestamp', Array(Array(((is_array($in) && isset($in['revisionId'])) ? $in['revisionId'] : null),'flow-edited-ago'),Array()), 'encq').' '.((LCRun3::ifvar($cx, ((is_array($in['links']) && isset($in['links']['diff-prev'])) ? $in['links']['diff-prev'] : null))) ? ' </a> ' : '').' • ' : '').' - '.LCRun3::ch($cx, 'uuidTimestamp', Array(Array(((is_array($in) && isset($in['postId'])) ? $in['postId'] : null),'time_ago'),Array()), 'encq').' + '.LCRun3::ch($cx, 'uuidTimestamp', Array(Array(((is_array($in) && isset($in['postId'])) ? $in['postId'] : null),'flow-time-ago'),Array()), 'encq').' </div> <div class="flow-menu"> diff --git a/handlebars/compiled/flow_block_topic_moderate_topic.handlebars.php b/handlebars/compiled/flow_block_topic_moderate_topic.handlebars.php index 748eba5..4bbd2fb 100644 --- a/handlebars/compiled/flow_block_topic_moderate_topic.handlebars.php +++ b/handlebars/compiled/flow_block_topic_moderate_topic.handlebars.php @@ -151,13 +151,13 @@ class="mw-ui-progressive mw-ui-quiet" title="'.htmlentities(((is_array($in['links']['diff-prev']) && isset($in['links']['diff-prev']['title'])) ? $in['links']['diff-prev']['title'] : null), ENT_QUOTES, 'UTF-8').'"> ' : '').' - '.LCRun3::ch($cx, 'uuidTimestamp', Array(Array(((is_array($in) && isset($in['revisionId'])) ? $in['revisionId'] : null),'edited_ago'),Array()), 'encq').' + '.LCRun3::ch($cx, 'uuidTimestamp', Array(Array(((is_array($in) && isset($in['revisionId'])) ? $in['revisionId'] : null),'flow-edited-ago'),Array()), 'encq').' '.((LCRun3::ifvar($cx, ((is_array($in['links']) && isset($in['links']['diff-prev'])) ? $in['links']['diff-prev'] : null))) ? ' </a> ' : '').' • ' : '').' - '.LCRun3::ch($cx, 'uuidTimestamp', Array(Array(((is_array($in) && isset($in['postId'])) ? $in['postId'] : null),'time_ago'),Array()), 'encq').' + '.LCRun3::ch($cx, 'uuidTimestamp', Array(Array(((is_array($in) && isset($in['postId'])) ? $in['postId'] : null),'flow-time-ago'),Array()), 'encq').' </div> <div class="flow-menu"> diff --git a/handlebars/compiled/flow_block_topiclist.handlebars.php b/handlebars/compiled/flow_block_topiclist.handlebars.php index 7872202..41e22db 100644 --- a/handlebars/compiled/flow_block_topiclist.handlebars.php +++ b/handlebars/compiled/flow_block_topiclist.handlebars.php @@ -171,7 +171,9 @@ class="wikiglyph '.LCRun3::hbch($cx, 'ifEquals', Array(Array(((is_array($in) && isset($in['moderateState'])) ? $in['moderateState'] : null),'close'),Array()), $in, function($cx, $in) {return 'wikiglyph-stop';}).''.LCRun3::hbch($cx, 'ifEquals', Array(Array(((is_array($in) && isset($in['moderateState'])) ? $in['moderateState'] : null),'hide'),Array()), $in, function($cx, $in) {return 'wikiglyph-flag';}).''.LCRun3::hbch($cx, 'ifEquals', Array(Array(((is_array($in) && isset($in['moderateState'])) ? $in['moderateState'] : null),'delete'),Array()), $in, function($cx, $in) {return 'wikiglyph-trash';}).'"></span> '.LCRun3::ch($cx, 'l10n', Array(Array('post_moderation_state',((is_array($in) && isset($in['moderateState'])) ? $in['moderateState'] : null),((is_array($in) && isset($in['replyToId'])) ? $in['replyToId'] : null),((is_array($in['moderator']) && isset($in['moderator']['name'])) ? $in['moderator']['name'] : null)),Array()), 'encq').'</div> ' : '').' -<span class="flow-author">'.LCRun3::ch($cx, 'l10n', Array(Array('started_with_participants',$in),Array()), 'encq').'</span> +<span class="flow-author"> + '.LCRun3::ch($cx, 'l10n', Array(Array('flow-topic-participants',((is_array($in) && isset($in['author_count'])) ? $in['author_count'] : null),((is_array($in) && isset($in['unnamed_author_count'])) ? $in['unnamed_author_count'] : null),((is_array($in['creator']) && isset($in['creator']['name'])) ? $in['creator']['name'] : null),((is_array($in) && isset($in['last_author_name'])) ? $in['last_author_name'] : null)),Array()), 'encq').' +</span> <div class="flow-topic-meta"> '.((LCRun3::ifvar($cx, ((is_array($in['actions']) && isset($in['actions']['reply'])) ? $in['actions']['reply'] : null))) ? ' <a href="#flow-post-'.htmlentities(((is_array($in) && isset($in['postId'])) ? $in['postId'] : null), ENT_QUOTES, 'UTF-8').'-form-content" diff --git a/handlebars/flow_topic_titlebar_content.handlebars b/handlebars/flow_topic_titlebar_content.handlebars index e546faf..27d2b50 100644 --- a/handlebars/flow_topic_titlebar_content.handlebars +++ b/handlebars/flow_topic_titlebar_content.handlebars @@ -5,7 +5,9 @@ {{l10n "post_moderation_state" moderateState replyToId moderator.name~}} </div> {{/if}} -<span class="flow-author">{{l10n "started_with_participants" this}}</span> +<span class="flow-author"> + {{l10n "flow-topic-participants" author_count unnamed_author_count creator.name last_author_name}} +</span> <div class="flow-topic-meta"> {{#if actions.reply}} <a href="#flow-post-{{postId}}-form-content" diff --git a/i18n/en.json b/i18n/en.json index 954d4d7..887110f 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -206,7 +206,7 @@ "flow-history-week": "Last week", "flow-history-pages-topic": "Appears on [$1 \"$2\" board]", "flow-history-pages-post": "Appears on [$1 $2]", - "flow-topic-participants": "{{PLURAL:$1|$3 started this topic|{{GENDER:$3|$3}}, {{GENDER:$4|$4}}, {{GENDER:$5|$5}} and $2 {{PLURAL:$2|other|others}}|0=No participation yet|2={{GENDER:$3|$3}} and {{GENDER:$4|$4}}|3={{GENDER:$3|$3}}, {{GENDER:$4|$4}} and {{GENDER:$5|$5}}}}", + "flow-topic-participants": "{{PLURAL:$1|$3 started this topic|{{GENDER:$3|$3}}, {{GENDER:$4|$4}} and $2 {{PLURAL:$2|other|others}}|0=No participation yet|2={{GENDER:$3|$3}} and {{GENDER:$4|$4}}}}", "flow-topic-comments": "{{PLURAL:$1|$1 comment|$1 comments|0={{GENDER:$2|Be the first}} to comment!}}", "flow-comment-restored": "Restored comment", "flow-comment-deleted": "Deleted comment", @@ -320,7 +320,6 @@ "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-cancel-warning": "You have entered text in this form. Are you sure you want to discard it?", "flow-topic-first-heading": "Topic on $1", - "flow-topic-participants-second-try": "{{PLURAL:$2|0=$1 {{GENDER:$1|started}} this topic|1=$1 {{GENDER:$1|started}} this topic and there was one other participant|$1 {{GENDER:$1|started}} this topic and there were $2 other participants}}", "flow-topic-count-sidebar": "Showing $1 of $2 topics attached to this page", "flow-topic-count": "Topics ($1)", "flow-active-ago": "Active $1", diff --git a/i18n/qqq.json b/i18n/qqq.json index 19880e3..e7b2f47 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -210,7 +210,7 @@ "flow-history-week": "Used as <code><nowiki><h2></nowiki></code> heading in the \"Topic history\" page to display all history of last week.\n\nThis \"Last week\" is equal to \"Last 7 days\".\n{{Identical|Last week}}", "flow-history-pages-topic": "Used to describe what board the topic is added to. Parameters:\n* $1 - the link to the page\n* $2 - the page title", "flow-history-pages-post": "Used to describe what topic the post is added to. Parameters:\n* $1 - the link to the topic\n* $2 - the topic title", - "flow-topic-participants": "Message to display the amount of participants in this topic (and potentially a couple of names).\n\nParameters:\n* $1 - the total amount of participants in the conversation, can be used for PLURAL\n* $2 - the total amount of participants minus 3, can be used to generate a message like: X, Y, Z and $2 others ($3, $4 and $5 will be usernames)\n* $3 - username of the topic starter, can be used for GENDER\n* $4 - username of the most recent participant (if there is a second participant, otherwise not available), can be used for GENDER\n* $5 - username of the second most recent participant (if there is a third participant, otherwise not available), can be used for GENDER", + "flow-topic-participants": "Message to display the amount of participants in this topic (and potentially a couple of names).\n\nParameters:\n* $1 - the total amount of participants in the conversation, can be used for PLURAL\n* $2 - the total amount of participants minus 3, can be used to generate a message like: X, Y, Z and $2 others ($3, $4 and $5 will be usernames)\n* $3 - username of the topic starter, can be used for GENDER\n* $4 - username of the most recent participant who is not the creator (if there is a second participant, otherwise not available), can be used for GENDER", "flow-topic-comments": "Message to display the amount of comments in this topic. Shown as a link after the topic title and the line with the topic authors. Clicking the link lets the current user write a new comment.\n\nParameters:\n* $1 - the number of comments on this topic, can be used for PLURAL\n* $2 - the name of the current user, can be used for GENDER\nSee also:\n* {{msg-mw|Flow-topic-meta-minimal}}", "flow-comment-restored": "Used as revision comment when the post has been restored.\n\nSee also:\n* {{msg-mw|Flow-comment-deleted}}", "flow-comment-deleted": "Used as revision comment when the post has been deleted.\n\nSee also:\n* {{msg-mw|Flow-comment-restored}}", @@ -324,7 +324,6 @@ "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-cancel-warning": "Warning message to be displayed when user tries to discard the text they have entered in a form field", "flow-topic-first-heading": "First heading on any page in the topic namespace. Parameters:\n* $1 - the title of the page that is being linked to", - "flow-topic-participants-second-try": "Message to display the amount of participants in this topic (and potentially a couple of names).\n\nParameters:\n* $1 - The username that created the topic.\n* $2 - The number of participants in the topic in addition to the topic creator.", "flow-topic-count-sidebar": "Message displayed at the bottom of the sidebar showing the number of topics current displayed and the total available.", "flow-topic-count": "Message displayed at the top of the sidebar showing the number of topics loaded on the page\n{{Identical|Topic}}", "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}}", diff --git a/includes/Formatter/TopicFormatter.php b/includes/Formatter/TopicFormatter.php index d416796..5baddce 100644 --- a/includes/Formatter/TopicFormatter.php +++ b/includes/Formatter/TopicFormatter.php @@ -94,7 +94,7 @@ do { $data = $stack->pop(); $replies++; - $authors[] = $data['author']['wiki'] . "\t" . $data['author']['name']; + $authors[] = $data['creator']['name']; foreach ( $data['replies'] as $postId ) { $stack->push( $revisions[$posts[$postId][0]] ); } @@ -102,9 +102,14 @@ $workflow = isset( $workflows[$postAlphaId] ) ? $workflows[$postAlphaId] : null; + $authors = array_unique( $authors ); + $authorCount = count( $authors ); + $lastAuthor = end( $authors ); return array( 'reply_count' => $replies, - 'author_count' => count( array_unique( $authors ) ), + 'unnamed_author_count' => $lastAuthor === $authors[0] ? $authorCount - 1 : $authorCount - 2, + 'last_author_name' => $lastAuthor, + 'author_count' => $authorCount, // ms timestamp 'last_updated' => $workflow ? $workflow->getLastModifiedObj()->getTimestamp() * 1000 : null, ); diff --git a/includes/Formatter/TopicListFormatter.php b/includes/Formatter/TopicListFormatter.php index d3d90da..f745197 100644 --- a/includes/Formatter/TopicListFormatter.php +++ b/includes/Formatter/TopicListFormatter.php @@ -150,7 +150,7 @@ do { $data = $stack->pop(); $replies++; - $authors[] = $data['author']['wiki'] . "\t" . $data['author']['name']; + $authors[] = $data['creator']['name']; foreach ( $data['replies'] as $postId ) { $stack->push( $revisions[$posts[$postId][0]] ); } @@ -158,9 +158,14 @@ $workflow = isset( $workflows[$postAlphaId] ) ? $workflows[$postAlphaId] : null; + $authors = array_unique( $authors ); + $authorCount = count( $authors ); + $lastAuthor = end( $authors ); return array( 'reply_count' => $replies, - 'author_count' => count( array_unique( $authors ) ), + 'unnamed_author_count' => $lastAuthor === $authors[0] ? $authorCount - 1 : $authorCount - 2, + 'last_author_name' => $lastAuthor, + 'author_count' => $authorCount, // ms timestamp 'last_updated' => $workflow ? $workflow->getLastModifiedObj()->getTimestamp() * 1000 : null, ); diff --git a/includes/TemplateHelper.php b/includes/TemplateHelper.php index 8f133c3..a6c71b7 100644 --- a/includes/TemplateHelper.php +++ b/includes/TemplateHelper.php @@ -205,15 +205,6 @@ $message = wfMessage( $str, $moderator ); break; - case 'started_with_participants': - $topicTitle = $args[0]; - $message = wfMessage( - 'flow-topic-participants-second-try', - $topicTitle['creator']['name'], - $topicTitle['author_count'] - 1 - ); - break; - case 'time': // This one is not used right now. The parsing of // "x time ago" is done client-side (see its radically different diff --git a/modules/new/flow-handlebars.js b/modules/new/flow-handlebars.js index f6d0e65..3f6baf1 100644 --- a/modules/new/flow-handlebars.js +++ b/modules/new/flow-handlebars.js @@ -164,14 +164,6 @@ function flowMessages( str ) { var parameters = Array.prototype.slice.call( arguments, 1 ), strings = ( { - // @todo - use real i18n message keys instead of cancatenation - "started_with_participants": function ( context, options ) { - return context.creator.name + " started this topic" + - ( context.author_count > 1 ? ( - ", with " + ( context.author_count - 1 ) + " other participant" + - ( context.author_count > 2 ? 's' : '' ) - ) : '' ); - }, "post_moderation_state": function( type, replyToId, name ) { var str; if ( !replyToId ) { -- To view, visit https://gerrit.wikimedia.org/r/155827 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ia45427ddf74bb7b74c7dd5e341507b3cff065097 Gerrit-PatchSet: 15 Gerrit-Project: mediawiki/extensions/Flow Gerrit-Branch: master Gerrit-Owner: Jdlrobson <jrob...@wikimedia.org> Gerrit-Reviewer: Matthias Mullie <mmul...@wikimedia.org> Gerrit-Reviewer: SG <shah...@gmail.com> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits