Page MenuHomePhabricator

CategoryTree should have built-in localizable support for pretty Categorytree-member-num
Closed, ResolvedPublic

Description

Many Wikipedias customized MediaWiki:Categorytree-member-num to show the number of sub-categories, pages and files in the parentheses after the category name, something like (3 C, 5 P, 1 F). Even for English this requires rather weird parser function tricks to make the comma appear in the correct places, and other languages need even stranger tricks - for example in Hebrew "one" comes after the noun, but other numbers come before it, so i had to use #switch and jump through even more hoops to get the comma appear correctly.

I checked the 20 largest Wikipedias and MediaWiki:Categorytree-member-num was customized in all of them in much the same way. Since there apparently is demand for this feature and the eventual functionality is quite the same everywhere, it should be done this way:

  1. There should be abbreviated localizable messages for C, P and F (category, page, file), something like:

categorytree-category-count-short: {{PLURAL:$1|1 C|$1 C}}
categorytree-page-count-short: {{PLURAL:$1|1 P|$1 P}}
categorytree-file-count-short: {{PLURAL:$1|1 F|$1 F}}

  1. Then after the category name all the non-zero values can be shown, joined by a comma on the extension code level.
  1. If all the values are zeroes, the word "empty" should be shown. (There should be another localizable message for this.)

I didn't find any project that implemented this differently, but if there is such a project, it can keep using Categorytree-member-num.


Version: unspecified
Severity: enhancement

Details

Reference
bz29357

Related Objects

View Standalone Graph
This task is connected to more than 200 other tasks. Only direct parents and subtasks are shown here. Use View Standalone Graph to show more of the graph.

Event Timeline

bzimport raised the priority of this task from to Normal.Nov 21 2014, 11:31 PM
bzimport set Reference to bz29357.
Amire80 created this task.Jun 12 2011, 6:36 AM

Is this information something we want to display by default, and is this the format we want to display it?

(In reply to comment #1)

Is this information something we want to display by default, and is this the
format we want to display it?

Well, see above - it was enabled and customized in a nearly identical way in many Wikipedias, so the answer is probably yes.

Amir volunteered during triage. Brain offered to assist Amir when needed.

Created attachment 9073
Patch to fix the problem. Should be tested.

Added the messages:

  • categorytree-num-categories
  • categorytree-num-pages
  • categorytree-num-files
  • categorytree-num-empty

Added documentation for all of them and for categorytree-member-num and also localized them for Hebrew.

Rewrote the part that uses categorytree-member-num to automatically create a comma-separated list of relevant member counts. categorytree-member-num will still be used the same way if it is customized on wiki.

attachment member-num-patch.patch ignored as obsolete

The patch looks fine. Few notes though:

  • array_push is not commonly used when appendin elements to array. The shorthand $array[] = $elem; is much more common.
  • It lacks some whitespace according to your style guide. Do you know /trunk/tools/code-utils/stylize.php?
  • I see that the div has dir depending on the interface language, but has literate RLM/LRM marker in content language inside, is that correct?

(In reply to comment #5)

The patch looks fine. Few notes though:

  • array_push is not commonly used when appendin elements to array. The

shorthand $array[] = $elem; is much more common.

It's a Perlism :)

  • It lacks some whitespace according to your style guide. Do you know

/trunk/tools/code-utils/stylize.php?

No, thanks for telling.

  • I see that the div has dir depending on the interface language, but has

literate RLM/LRM marker in content language inside, is that correct?

Yes, it's correct and it was there before my change. Without it a category with an LTR title in an RTL wiki is displayed incorrectly.

Created attachment 9075
the same patch with fixes according to Niklas' comments

The same patch with fixes according to Niklas' comments - stylize and '$memberNums[] =' instead of 'array_push'.

Attached:

Applied in r100023.

  • Bug 26405 has been marked as a duplicate of this bug. ***