Page MenuHomePhabricator

SemanticMediaWiki: Canonical namespace names are set incorrectly.
Closed, ResolvedPublic

Description

Author: van.de.bugger

Description:
MediaWiki setups namespaces incorrectly. English (canonical) namespace names are set as namespace aliases. This is wrong, because MWNamespace::getCanonicalName( SMW_NS_PROPERTY ) returns "Свойство", not expected "Property".

To setup namespaces correctly:

  1. Create file "SMW_Namespaces.php" with content:

$namespaceNames = array();
$namespaceAliases = array();

$namespaceNames[ 'en' ] = array(

SMW_NS_PROPERTY   => 'Property',
...

);
$namespaceAliases[ 'en' ] = array(

...

);

$namespaceNames[ 'xx' ] = array(

SMW_NS_PROPERTY  => 'Localised name',

);
$namespaceAliases[ 'xx' ] = array(

...

);

  1. Let MediaWiki know about namespace:

$wgExtensionMessagesFiles[ 'SMW_Namespaces' ] = ".../SMW_Namespaces.php";

  1. Canonical namespace names must be setup via hook:

$wgHooks[ 'CanonicalNamespaces' ][] = 'SMW_onCanonicalNamespaceNames';

  1. The hook body:

function SMW_onCanonicalNamespaceNames( &$namespaces ) {

$namespaces += array(
    SMW_NS_PROPERTY => 'Property',
    ...
);
return true;

} // function ocCanonicalNamespaceNames

In such a case everything works as expected -- users see localized namespace names, while MWNamespace::getCanonicalName() returns English name.


Version: unspecified
Severity: normal

Details

Reference
bz34383

Event Timeline

bzimport raised the priority of this task from to Needs Triage.Nov 22 2014, 12:13 AM
bzimport set Reference to bz34383.

Confirmed. Will take care of this soonish. Thanks for the "patch"! :)

van.de.bugger wrote:

BTW, SemanticForms has the same issue. Should I open a separate bug?

Nah, I'll just fix it there as well :)

Can you verify the behavior in SMW after r111507?

van.de.bugger wrote:

Verified on r111537. Yes, it works. If I add my localization to SMW_Namespaces.php, a user see localized namespace names, WNamespace::getCanonicalName returns canonical names.

But change does not look completed. If seems you have to move following pieces of code:

protected $m_Namespaces = array(

SMW_NS_PROPERTY       => 'Property',
SMW_NS_PROPERTY_TALK  => 'Property_talk',
SMW_NS_TYPE           => 'Type',
SMW_NS_TYPE_TALK      => 'Type_talk',
SMW_NS_CONCEPT        => 'Concept',
SMW_NS_CONCEPT_TALK   => 'Concept_talk'

);

from every SMW_LanguageXX.php to SMW_Namespaces.php, and , probably, drop all the namespace-related stuff from SMWLanguage class.

Right, I only moved the EN stuff over. Can make the changes and provide them in the form of a patch?

Yeah, revert, the canonical hook was apparently added in 1.17. So will have to wait for SMW 1.8, which is probably the next rel after 1.7.1.

Unknown Object (User) added a comment.Nov 7 2012, 6:36 AM

Jeroen, now that we are on SMW 1.8 any issue to re-apply the patch?