Topic on Project:Support desk

How can I add a localized name to a custom namespace?

15
Jan Sende (talkcontribs)

Hey guys, I followed the manual for adding a custom namespace via LocalSettings.php and it works fine. However i want to display it's text differently in multiple languages. How can I achieve that? I tried using variants of:<br\> $namespaceNames['de'] = array( NS_EXERCISES => 'Übungen', NS_EXERCISES_TALK => 'Übungen_Diskussion', );<br\> But nothing happens. I even tried modifying the variables directly in the language file, but still nothing happened. So, what is the right way to do this?

Nemo bis (talkcontribs)
This post was hidden by 87.123.23.254 (history)
Sergezolotukhin (talkcontribs)

Try $wgExtraNamespaces[NS_EXERCISES ] = "Übungen";

87.123.23.254 (talkcontribs)

I don't see how $wgExtraNamespaces would display the name differently depending on language.

Sergezolotukhin (talkcontribs)

Oh. I read the question no closely

Ciencia Al Poder (talkcontribs)

You can define an alias for a namespace, for example, Image: is an alias for File:, but, only one of those alias is the main one and the one that will be displayed and used by MediaWiki. You can link a page using an alias namespace, but it will point to the "canonical" namespace name.

So if you define german aliases for english custom namespaces, you can use them to link to pages of that namespace, but when your users follow that link they'll see the english namespace and not the german one.

It can't be done per "user language", because that will break the cache, URLs (namespace is part of the URL) and who knows what other things.

Sergezolotukhin (talkcontribs)
Ciencia Al Poder (talkcontribs)

As I said, it doesn't work per "user language". Служебная:Спецстраницы doesn't work on any english wiki, no matter if your language is set to russian.

Sergezolotukhin (talkcontribs)

yes. but it works in russian site and this is I want to get. something like

def NS_EXERCISES = 3000;

wgLocalizedNs[NS_EXERCISES] = ['en' => 'new ns', 'ru' => 'новая ns' ... ]

87.123.2.204 (talkcontribs)

So the answer is: If you want to link to a namespace, then this only is possible with its real name.

However, the name, which is displayed on a namespace tab, this name omes from an interface message. And interface messages can be localized. That way it should be possible to display a different name on the tab and this depending on user language. I don't know how confusing this might be, but technically it should be possible.

Ciencia Al Poder (talkcontribs)

Using aliases you can link with an alias or the real name. However only the real name will be displayed on the URL and the page title.

Sergezolotukhin (talkcontribs)

I have this solution:

LocalSettings.php:

define("NS_STORY", 3000);

define("NS_STORY_TALK", 3001);

$wgExtraNamespaces[NS_STORY] = "Story";

$wgNamespaceProtection[NS_STORY] = array( 'edit-story' );

$wgGroupPermissions['*']['edit-story'] = true;

...

require_once "$IP/../hosting.settings.php";

hosting.settings.php:

switch ( $_SERVER['HTTP_HOST'] ) {

case 'ru.xxx.wiki':

$wgServer = "http://ru.xxx.wiki";

$wgFileCacheDirectory = "/var/cache/ru.xxx.wiki";

$wgDBname = "xxx_ru";

$wgShellLocale = "ru_RU.utf8";

$wgLanguageCode = "ru";

$wgExtraNamespaces[NS_STORY] = "Истории"; // just redefine!

break;

}

so on...

Ciencia Al Poder (talkcontribs)

Do you mean the same wiki and database is accessible from different hosts? You'll have broken links browsing your wiki as unregistered user unless you disable all caching. Saving an edit on the ru.* host will save links to that namespace as Истории but the other host will also display links as that, where that namespace is not defined.

Sergezolotukhin (talkcontribs)

no. databases are different, but templates (and scripts, including LocalSettings.php) are the same.

Reply to "How can I add a localized name to a custom namespace?"