Adrian Heine has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/281932

Change subject: Improve sitelinks and references counter messages
......................................................................

Improve sitelinks and references counter messages

Bug: T57961
Bug: T72838
Change-Id: Ic38ea034b1f644cc43e278025d1c312f4e0e1a8a
---
M repo/i18n/en.json
M repo/i18n/qqq.json
M view/resources/jquery/wikibase/jquery.wikibase.sitelinklistview.js
M view/resources/jquery/wikibase/jquery.wikibase.statementview.js
M view/resources/jquery/wikibase/resources.php
M view/resources/wikibase/utilities/resources.php
M view/resources/wikibase/utilities/wikibase.utilities.ui.js
M view/src/ClaimHtmlGenerator.php
M view/src/SiteLinksView.php
M view/tests/phpunit/SiteLinksViewTest.php
10 files changed, 27 insertions(+), 58 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/32/281932/1

diff --git a/repo/i18n/en.json b/repo/i18n/en.json
index a74bbda..8d5310d 100644
--- a/repo/i18n/en.json
+++ b/repo/i18n/en.json
@@ -79,11 +79,7 @@
        "wikibase-undo-badpage": "Bad revision: Revision $2 does not belong to 
[[$1]].",
        "wikibase-undo-firstrev": "Cannot undo the page's creation",
        "wikibase-undo-nocontent": "Cannot load content of revision $2 of page 
$1",
-       "wikibase-ui-pendingquantitycounter-nonpending": "$2 $1",
-       "wikibase-ui-pendingquantitycounter-pending": "$2$3 $1",
-       "wikibase-ui-pendingquantitycounter-pending-pendingsubpart": "+$1",
        "wikibase-propertyedittool-counter-pending-tooltip": "{{PLURAL:$1|One 
value|$1 values}} not saved yet",
-       "wikibase-propertyedittool-counter-entrieslabel": 
"{{PLURAL:$1|entry|entries}}",
        "wikibase-disambiguation-title": "Disambiguation for \"$1\"",
        "wb-special-newitem-new-item-notification": "New item $1 created and 
redirected to its page. Back to $2.",
        "wikibase-aliases-input-help-message": "To make this entity easier to 
find, you can enter alternative names.",
@@ -93,10 +89,11 @@
        "wikibase-property-footer": "",
        "wikibase-claimview-snak-tooltip": "Enter a value corresponding to the 
property named \"$1\". If the property has no designated value or the actual 
value is not known, you may choose an alternative to specifying a custom value 
by clicking the icon next to the value input box.",
        "wikibase-claimview-snak-new-tooltip": "After specifying a property you 
can enter a corresponding value. If the property has no designated value or the 
actual value is not known, you may choose an alternative to specifying a custom 
value by clicking the icon next to the value input box.",
+       "wikibase-sitelinks-counter": 
"$1{{PLURAL:$2|0={{PLURAL:0}}|TIPSY_PLACEHOLDER(+$2)}} 
{{PLURAL:$1|entry|entries}}",
        "wikibase-statementview-rank-preferred": "Preferred rank",
        "wikibase-statementview-rank-normal": "Normal rank",
        "wikibase-statementview-rank-deprecated": "Deprecated rank",
-       "wikibase-statementview-referencesheading-pendingcountersubject": 
"{{PLURAL:$1|reference|references}}",
+       "wikibase-statementview-referencescounter": 
"$1{{PLURAL:$2|0={{PLURAL:0}}|TIPSY_PLACEHOLDER(+$2)}} 
{{PLURAL:$1|reference|references}}",
        "wikibase-statementview-referencesheading-pendingcountertooltip": 
"{{PLURAL:$1|One reference|$1 references}} not saved yet",
        "wikibase-snakview-property-input-placeholder": "property",
        "wikibase-snakview-unsupportedsnaktype": "Snak of type \"$1\". Handling 
for this kind of Snak is not yet supported.",
diff --git a/repo/i18n/qqq.json b/repo/i18n/qqq.json
index ffe28d8..3d1a9b6 100644
--- a/repo/i18n/qqq.json
+++ b/repo/i18n/qqq.json
@@ -110,11 +110,7 @@
        "wikibase-undo-badpage": "Message shown when the user attempts to undo 
the difference between two revisions belonging to different pages. The first 
argument is the name of the page, the second is the revision 
id.\n\nParameters:\n* $1 - the title of the page\n* $2 - the revision id 
number",
        "wikibase-undo-firstrev": "Message shown when the user attempts to undo 
the very first revision of a page, that is, the page's creation.",
        "wikibase-undo-nocontent": "Message shown when the content of one of 
the revisions needed for undo could not be loaded.\nThis may happen if there is 
an error in the storage backend, or if the respective revision has been hidden 
(oversighted) or deleted.\n* $1 - the title of the page\n* $2 - the revision 
ID",
-       "wikibase-ui-pendingquantitycounter-nonpending": "Message for a generic 
counter which will display a quantity and of what nature that quantity 
is.\n\nParameters:\n* $1 - the label of the counter's subject. E.g. 
'references' in an item's statement's references counter displayed in the 
heading above the references. This is any one of the following messages:\n** 
{{msg-mw|Wikibase-propertyedittool-counter-entrieslabel}}\n** 
{{msg-mw|Wikibase-statementview-referencesheading-pendingcountersubject}}\n* $2 
- the number the quantity the counter is currently displaying. E.g. on an item 
page, the entries in the list of Wikipedia pages linked to the item.",
-       "wikibase-ui-pendingquantitycounter-pending": "Message for a generic 
counter which will display a fixed quantity as well as a non-fixed, pending 
quantity and of what nature those quantities are.\n\nParameters:\n* $1 - the 
label of the counter's subject. E.g. 'references' in an item's statement's 
references counter displayed in the heading above the references.\n* $2 - the 
fixed quantity of the counter. The fixed quantity can for example be the number 
of site-links in an item's site-links table which are already saved and 
permanently displayed in the table, ready to be edited by the user.\n* $3 - the 
pending quantity of the counter with some additional markup around, expressing 
and explaining the pending nature of the number. Basically, this is the content 
of {{msg-mw|Wikibase-ui-pendingquantitycounter-pending-pendingsubpart}}. The 
pending quantity can for example be the number of site-links in an item's 
site-links table which are not yet saved.",
-       "wikibase-ui-pendingquantitycounter-pending-pendingsubpart": 
"{{optional}}\nThe pending quantity of a counter and a leading '+'.\n\nThe 
pending quantity of a counter can for example be the number of site-links in an 
item's site-links table which are not yet saved.\n\nUsed as <code>$3</code> in 
{{msg-mw|Wikibase-ui-pendingquantitycounter-pending}}.",
        "wikibase-propertyedittool-counter-pending-tooltip": "Parameters:\n* $1 
is the number of elements not saved yet.",
-       "wikibase-propertyedittool-counter-entrieslabel": "Used in the counter 
on top of the site-links table.\n\nThe counter is giving information about how 
many site-links exist in the following table.\n\nThis is just the label for the 
counter's subject, the site-links.\n\nParameters:\n* $1 - the number of 
site-links (for PLURAL), not part of the message\n\nSee also:\n* 
{{msg-mw|Wikibase-ui-pendingquantitycounter-nonpending}}\n{{Identical|Entry}}",
        "wikibase-disambiguation-title": "Disambiguation page title. 
Parameters:\n* $1 - the label of the item being disambiguated",
        "wb-special-newitem-new-item-notification": "Message displayed when a 
new item was created on [[d:Special:NewItem]] and the user has been redirected 
to the new items page.\n\nParameters:\n* $1 - the new items id\n* $2 - a link 
back to the special page with \"special-newitem\" as label",
        "wikibase-aliases-input-help-message": "Bubble help message for 
entering the aliases of the data set used for a specific 
item.\n\nParameters:\n* $1 - (Unused) language 
name\n{{Related|Wikibase-input-help-message}}",
@@ -124,10 +120,11 @@
        "wikibase-property-footer": "Text displayed at the bottom of every 
property page.",
        "wikibase-claimview-snak-tooltip": "Tooltip message displayed when 
hovering/clicking the help icon next to the save, cancel and remove links of a 
claim (see [[d:Wikidata:Glossary#Claim]]).\n\nParameters:\n* $1 - the property 
name the user is about to edit a value of or add another value to",
        "wikibase-claimview-snak-new-tooltip": "Tooltip message displayed when 
hovering/clicking the help icon next to the save, cancel and remove links of a 
claim (see [[d:Wikidata:Glossary]]) when about to add a completely new claim 
which includes specifying the property.",
+       "wikibase-sitelinks-counter": "Used in the heading for a sitelink group 
(see [[d:Wikidata:Glossary]]). The heading is giving information about how many 
sitelinks exist in that sitelink group. This is the counter part of the heading 
without the parentheses.\n\nParameters:\n* $1 - the number of saved 
sitelinks\n* $2 - the number of unsaved sitelinks",
        "wikibase-statementview-rank-preferred": "Label of the 
[[d:Wikidata:Glossary#Rank-preferred|Preferred Rank]] item within the menu that 
allows adjusting a [[d:Wikidata:Glossary#Statement|Statement's]] 
[[d:Wikidata:Glossary#Rank|Rank]]. The message is additionally used as tooltip 
on the rank icon when the statement has assigned the Preferred rank.",
        "wikibase-statementview-rank-normal": "Label of the 
[[d:Wikidata:Glossary#Rank-normal|Normal Rank]] item within the menu that 
allows adjusting a [[d:Wikidata:Glossary#Statement|Statement's]] 
[[d:Wikidata:Glossary#Rank|Rank]]. The message is additionally used as tooltip 
on the rank icon when the statement has assigned the Normal Rank.",
        "wikibase-statementview-rank-deprecated": "Label of the 
[[d:Wikidata:Glossary#Rank-deprecated|Deprecated Rank]] item within the menu 
that allows adjusting a [[d:Wikidata:Glossary#Statement|Statement's]] 
[[d:Wikidata:Glossary#Rank|Rank]]. The message is additionally used as tooltip 
on the rank icon when the statement has assigned the Deprecated Rank.",
-       "wikibase-statementview-referencesheading-pendingcountersubject": "Used 
in the heading for the references associated with a statement (see 
[[d:Wikidata:Glossary]]). The heading is giving information about how many 
references exist for that statement. This is just the label for the counter's 
subject: the number of references is not part of this message, and the word 
order is defined via 
{{msg-mw|wikibase-ui-pendingquantitycounter-nonpending}}.\n\nParameters:\n* $1 
- the number of references for plural usage\n{{Identical|Source}}",
+       "wikibase-statementview-referencescounter": "Used in the heading for 
the references associated with a statement (see [[d:Wikidata:Glossary]]). The 
heading is giving information about how many references exist for that 
statement. This is the whole heading.\n\nParameters:\n* $1 - the number of 
saved references\n* $2 - the number of unsaved references",
        "wikibase-statementview-referencesheading-pendingcountertooltip": 
"Tooltip displayed in the references heading when there are references (see 
[[d:Wikidata:Glossary]]) in edit mode which are not saved 
yet.\n\nParameters:\n* $1 - the number of elements not saved yet",
        "wikibase-snakview-property-input-placeholder": "Placeholder message 
that is initially displayed within the property input element when adding a new 
snak. See also [[d:Wikidata:Glossary]].\n{{Identical|Property}}",
        "wikibase-snakview-unsupportedsnaktype": "Parameters:\n* $1 - snak 
type\nSee [[d:Wikidata:Glossary#Snak]].\n\nSnaks are the basic information 
structures used to describe Entities in Wikidata. They are an integral part of 
each Statement (which can be viewed as collection of Snaks about an Entity, 
together with a list of references).\n\nEx:\n*Berlin (subject) has a population 
(property) of 3499879 (value).\n*Georgia (subject) has the capital (property) 
Tbilisi (value).\n*Ghandi (subject) was born on (property) 2 October 1869 
(value).",
diff --git a/view/resources/jquery/wikibase/jquery.wikibase.sitelinklistview.js 
b/view/resources/jquery/wikibase/jquery.wikibase.sitelinklistview.js
index 5b80987..670485c 100644
--- a/view/resources/jquery/wikibase/jquery.wikibase.sitelinklistview.js
+++ b/view/resources/jquery/wikibase/jquery.wikibase.sitelinklistview.js
@@ -306,7 +306,7 @@
                var $counterMsg = wb.utilities.ui.buildPendingCounter(
                        $items.length - $pendingItems.length,
                        $pendingItems.length,
-                       'wikibase-propertyedittool-counter-entrieslabel',
+                       'wikibase-sitelinks-counter',
                        'wikibase-propertyedittool-counter-pending-tooltip'
                );
 
diff --git a/view/resources/jquery/wikibase/jquery.wikibase.statementview.js 
b/view/resources/jquery/wikibase/jquery.wikibase.statementview.js
index 8c71553..55a970b 100644
--- a/view/resources/jquery/wikibase/jquery.wikibase.statementview.js
+++ b/view/resources/jquery/wikibase/jquery.wikibase.statementview.js
@@ -619,7 +619,7 @@
                var $counterMsg = wb.utilities.ui.buildPendingCounter(
                        numberOfValues,
                        numberOfPendingValues,
-                       
'wikibase-statementview-referencesheading-pendingcountersubject',
+                       'wikibase-statementview-referencescounter',
                        
'wikibase-statementview-referencesheading-pendingcountertooltip' );
 
                // update counter, don't touch the toggle!
diff --git a/view/resources/jquery/wikibase/resources.php 
b/view/resources/jquery/wikibase/resources.php
index 7efe3e4..a7a348d 100644
--- a/view/resources/jquery/wikibase/resources.php
+++ b/view/resources/jquery/wikibase/resources.php
@@ -350,7 +350,7 @@
                        ),
                        'messages' => array(
                                'parentheses',
-                               
'wikibase-propertyedittool-counter-entrieslabel',
+                               'wikibase-sitelinks-counter',
                                
'wikibase-propertyedittool-counter-pending-tooltip',
                        ),
                ),
@@ -422,7 +422,7 @@
                                'wikibase-statementview-rank-preferred',
                                'wikibase-statementview-rank-normal',
                                'wikibase-statementview-rank-deprecated',
-                               
'wikibase-statementview-referencesheading-pendingcountersubject',
+                               'wikibase-statementview-referencescounter',
                                
'wikibase-statementview-referencesheading-pendingcountertooltip',
                        ),
                ),
diff --git a/view/resources/wikibase/utilities/resources.php 
b/view/resources/wikibase/utilities/resources.php
index 5ace23f..96ec3c4 100644
--- a/view/resources/wikibase/utilities/resources.php
+++ b/view/resources/wikibase/utilities/resources.php
@@ -47,11 +47,7 @@
                                'wikibase',
                                'jquery.tipsy',
                                'mediawiki.language',
-                       ),
-                       'messages' => array(
-                               'wikibase-ui-pendingquantitycounter-nonpending',
-                               'wikibase-ui-pendingquantitycounter-pending',
-                               
'wikibase-ui-pendingquantitycounter-pending-pendingsubpart',
+                               'mediawiki.jqueryMsg'
                        ),
                ),
 
diff --git a/view/resources/wikibase/utilities/wikibase.utilities.ui.js 
b/view/resources/wikibase/utilities/wikibase.utilities.ui.js
index 6f406b9..195374e 100644
--- a/view/resources/wikibase/utilities/wikibase.utilities.ui.js
+++ b/view/resources/wikibase/utilities/wikibase.utilities.ui.js
@@ -33,44 +33,28 @@
         *
         * @param {number} fixedQuantity
         * @param {number} pendingQuantity
-        * @param {string} kindOfQuantityMessage Message string of a message 
expressing the nature of
-        *        the quantity, e.g. a message which would return 'items' for 
displaying something like
-        *        "3 +1 items". The message will receive as parameter $1 the 
total quantity (fixed +
-        *        pending).
+        * @param {string} mainMessage Message name of a message for the whole 
counter. The message
+        *        will receive as parameter $1 the fixed quantity, and as 
parameter $2 the number of
+        *        pending items.
         * @param {string} pendingQuantityTooltipMessage Message string of a 
message which will be
         *        displayed in the tooltip which will be appended to the number 
of pending quantity.
-        *        Parameter $1 will be the number of pending quantity, $2 will 
be the fixed quantity
-        *        and $3 the sum of both.
+        *        Parameter $1 will be the number of pending quantity.
         * @return {jQuery} The formatted counter output. Does not have a root 
node, collection of
         *         multiple DOM elements.
         */
        wb.utilities.ui.buildPendingCounter = function(
-               fixedQuantity, pendingQuantity, kindOfQuantityMessage, 
pendingQuantityTooltipMessage
+               fixedQuantity, pendingQuantity, mainMessage, 
pendingQuantityTooltipMessage
        ) {
                var fqNumMsg = mw.language.convertNumber( fixedQuantity ),
-                       pqNumMsg = mw.language.convertNumber( pendingQuantity ),
-                       tqNumMsg = mw.language.convertNumber( fixedQuantity + 
pendingQuantity ),
-                       qTypeLabel = kindOfQuantityMessage ? mw.msg( 
kindOfQuantityMessage, tqNumMsg ) : '';
+                       pqNumMsg = mw.language.convertNumber( pendingQuantity );
 
-               var msg = !pendingQuantity || pendingQuantity === '0'
-                       ? mw.msg( 
'wikibase-ui-pendingquantitycounter-nonpending', qTypeLabel, fqNumMsg )
-                       : mw.msg( 'wikibase-ui-pendingquantitycounter-pending',
-                               qTypeLabel,
-                               fqNumMsg,
-                               '__3__' // can't insert html here since it 
would be escaped!
-                       );
-
-               // replace __3__ with a span we can grab next
-               var $msg = $( ( '<span>' + msg + '</span>' ).replace( /__3__/g, 
'<span/>' ) ),
-                       $msgSpan = $msg.children( 'span' );
+               var $msg = $( '<span/>' ).html( mw.msg( mainMessage, fqNumMsg, 
pqNumMsg ).replace( /TIPSY_PLACEHOLDER\(([^)]+)\)/, '<span>$1</span>' ) );
+               var $msgSpan = $msg.children( 'span' );
 
                if ( $msgSpan.length > 0 ) {
                        $msgSpan.attr(
                                'title', // the message displayed in the tooltip
-                               mw.msg( pendingQuantityTooltipMessage, 
pqNumMsg, fqNumMsg, tqNumMsg )
-                       );
-                       $msgSpan.text( // the '+1' part, displaying the pending 
quantity
-                               mw.msg( 
'wikibase-ui-pendingquantitycounter-pending-pendingsubpart', pqNumMsg )
+                               mw.msg( pendingQuantityTooltipMessage, pqNumMsg 
)
                        );
                        $msgSpan.tipsy( {
                                gravity: ( IS_RTL ? 'ne' : 'nw' )
diff --git a/view/src/ClaimHtmlGenerator.php b/view/src/ClaimHtmlGenerator.php
index 3fbd740..3219ab7 100644
--- a/view/src/ClaimHtmlGenerator.php
+++ b/view/src/ClaimHtmlGenerator.php
@@ -205,11 +205,9 @@
                if ( !array_key_exists( $referenceCount, 
$this->referenceHeadings ) ) {
                        $formattedReferenceCount = 
$this->numberLocalizer->localizeNumber( $referenceCount );
                        $this->referenceHeadings[ $referenceCount ] = wfMessage(
-                               'wikibase-ui-pendingquantitycounter-nonpending',
-                               wfMessage(
-                                       
'wikibase-statementview-referencesheading-pendingcountersubject'
-                               )->params( $formattedReferenceCount )->text()
-                       )->params( $formattedReferenceCount )->text();
+                               'wikibase-statementview-referencescounter',
+                               $formattedReferenceCount
+                       )->text();
                }
 
                return $this->referenceHeadings[ $referenceCount ];
diff --git a/view/src/SiteLinksView.php b/view/src/SiteLinksView.php
index f355452..5d52aa5 100644
--- a/view/src/SiteLinksView.php
+++ b/view/src/SiteLinksView.php
@@ -157,9 +157,9 @@
                        wfMessage( 'wikibase-sitelinks-' . $group )->parse(),
                        wfMessage( 'parentheses',
                                wfMessage(
-                                       
'wikibase-ui-pendingquantitycounter-nonpending',
-                                       wfMessage( 
'wikibase-propertyedittool-counter-entrieslabel', $count ),
-                                       $count
+                                       'wikibase-sitelinks-counter',
+                                       $count, // FIXME: NumberLocalizer
+                                       0
                                )
                        ),
                        $this->templateFactory->render(
diff --git a/view/tests/phpunit/SiteLinksViewTest.php 
b/view/tests/phpunit/SiteLinksViewTest.php
index 5880b47..cc77a9f 100644
--- a/view/tests/phpunit/SiteLinksViewTest.php
+++ b/view/tests/phpunit/SiteLinksViewTest.php
@@ -51,8 +51,7 @@
                        '<h2 id="sitelinks" 
class="wikibase-sitelinks">(wikibase-sitelinks)</h2>'
                        . '<GROUP data="wikipedia" class="">'
                        . '<h3 
id="sitelinks-wikipedia">(wikibase-sitelinks-wikipedia)'
-                       . '(parentheses: 
(wikibase-ui-pendingquantitycounter-nonpending: '
-                       . '(wikibase-propertyedittool-counter-entrieslabel: 0), 
0))</h3>'
+                       . '(parentheses: (wikibase-sitelinks-counter: 0, 
0))</h3>'
                        . '</GROUP>',
                        $html
                );
@@ -68,8 +67,7 @@
                        '<h2 id="sitelinks" 
class="wikibase-sitelinks">(wikibase-sitelinks)</h2>'
                        . '<GROUP data="wikipedia" class="">'
                        . '<h3 
id="sitelinks-wikipedia">(wikibase-sitelinks-wikipedia)'
-                       . '(parentheses: 
(wikibase-ui-pendingquantitycounter-nonpending: '
-                       . '(wikibase-propertyedittool-counter-entrieslabel: 1), 
1))</h3>'
+                       . '(parentheses: (wikibase-sitelinks-counter: 1, 
0))</h3>'
                        . '<LINK id="enwiki" lang="en" title="&lt;LANG&gt;">'
                        . 'enwiki: <PAGE href="#enwiki" lang="en" 
dir="auto">Title</PAGE>'
                        . '</LINK>'
@@ -88,8 +86,7 @@
                        '<h2 id="sitelinks" 
class="wikibase-sitelinks">(wikibase-sitelinks)</h2>'
                        . '<GROUP data="special" class="">'
                        . '<h3 
id="sitelinks-special">(wikibase-sitelinks-special)'
-                       . '(parentheses: 
(wikibase-ui-pendingquantitycounter-nonpending: '
-                       . '(wikibase-propertyedittool-counter-entrieslabel: 1), 
1))</h3>'
+                       . '(parentheses: (wikibase-sitelinks-counter: 1, 
0))</h3>'
                        . '<LINK id="specialwiki" lang="en" 
title="(wikibase-sitelinks-sitename-specialwiki)">'
                        . 'specialwiki: <PAGE href="#specialwiki" lang="en" 
dir="auto">Title</PAGE>'
                        . '</LINK>'

-- 
To view, visit https://gerrit.wikimedia.org/r/281932
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic38ea034b1f644cc43e278025d1c312f4e0e1a8a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Adrian Heine <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to