Page MenuHomePhabricator

Special:Templates doesn´t look for localized category entries in template body
Closed, ResolvedPublic

Description

Author: u.baumbach

Description:
In SF_Templates.php function getCategoryDefinedByTemplate(...) looks for (least) category entry in each template body to show this as "defined category". Doing this a regex is used:

'/\[\[Category:([\w ]*)/'

So a potentially localized namespace name (in German "Kategorie:") cannot be found, only canonical "Category:"!

A solution might be:
In function getCategoryDefinedByTemplate(...):

  1. use of MediaWiki global variable $wgContLang
  2. replacement of the regexp with:

'/\[\[(Category|'.$wgContLang->getNsText(14).'):([\w ]*)/'


Version: unspecified
Severity: normal

Details

Reference
bz22318

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 10:46 PM
bzimport set Reference to bz22318.

u.baumbach wrote:

Use of option \w leads to the situation, that special characters in category names (e.g. ä, ö, ü, Ä, Ö, Ü, ß for Germans) -- that standard MediaWiki can handle -- "cut off" themselves and the rest of category name. So for a

Category:Mühle

parser only will find

Category:M

Seems to be better use of

'/\[\[(Category|'.$wgContLang->getNsText(14).'):.+\]\])/'

so at least one following character after ":", and cut off "]]" after this. So special characters could be accepted.

Thanks for the fix! This was added in SF version 1.8.8.

u.baumbach wrote:

To my sorrow you have implemented ONLY the localized form of category "name".

In my suggestion there was '...

'/\[\[(Category|'.$wgContLang->getNsText(14).'):.+\]\])/'

instead of

"/\[\[$cat_ns_name:(.*)\]\]/"

to assure that BOTH the standard English version AND the localized version $wgContLang->getNsText(14) can work.

u.baumbach wrote:

Should be

"/\[\[($cat_ns_name|Category):(.*)\]\]/"

But what if namespace aliases exist?

u.baumbach wrote:

NS alias for "Category"?

If so - it would fail, but who does such things?

But localized NS names are standard...

(In reply to comment #6)

If so - it would fail, but who does such things?

zhwiki does (though this will not be used there).

"Category" is the localized name there; "分类" and "分類" are aliases (in zh-hans and zh-hant).

Sorry - should have just copied your code in exactly the first time. It's now there, correctly, in v. 1.9. It still doesn't support category aliases, but I'm setting this to "FIXED" anyway.