Topic on Manual talk:Extension registration

How can I translate the namespace “name” to a local language the right way?

5
Summary last edited by Andreas Plank 07:58, 2 June 2021 2 years ago

One solution see post from 11. April 2019 17:31

I don’t know if it is the right way but it works for me ;-)

Andreas Plank (talkcontribs)

Hej-hej,

I asked for translating the default namespace (at extension talk of UploadWizard), how is it possible to do it the right way? $wgNamespaceAliases doesn’t help that much, because I want the translated namespace to appear (in search and display) not the default defined from extension.json. Any proper solution? Thanks.

Legoktm (talkcontribs)

Namespaces should be translated in the extension localization file, see this example in the Scribunto extension. I don't know why no one has done that for UploadWizard yet.

Jdforrester (WMF) (talkcontribs)
Jdforrester (WMF) (talkcontribs)

Yes, you add the name to $wgNamespaceAliases in local config of the wiki in question. For Wikimedia, you'd add that to the major InitialiseSettings.php file.

The alias only helps for manual linking; the URL is re-written by MediaWiki on browse (https://commons.wikimedia.org/wiki/COM:Deletion_requests becomes https://commons.wikimedia.org/wiki/Commons:Deletion_requests, etc.), so I'm not sure how valuable this would be. In general, MediaWiki's support for multi-lingual wikis is patchy, and this is one of those areas. Note also that there's a risk of whatever name you pick being subject to clashes, either with other desired aliases or for actual namespaces in future.

Currently, Commons only has language aliases/shorthands in English and for three namespaces ('Museum:'/'Museum_talk:' for 'Institution:'/'Institution_talk:', and 'COM:' for Commons:"). We could add a "translation" for NS_CAMPAIGN, but as this hasn't been done before I think it'd be best if there was a community discussion on Commons about that first.

Andreas Plank (talkcontribs)

In MW 1.30 I did the following:

if (! defined ("NS_CAMPAIGN" )) {
  define("NS_CAMPAIGN",        460);
  define("NS_CAMPAIGN_TALK",   461);
}
# rename untranslated Campaign
switch ($wgLanguageCode) {
  case "de":
  case "de-formal":
  case "de-at":
  case "de-ch":
    $wgExtraNamespaces[NS_CAMPAIGN]      = "Medienkampagne";
    $wgExtraNamespaces[NS_CAMPAIGN_TALK] = "Medienkampagne_Diskussion";
    $wgNamespaceAliases['Campaign'] = NS_CAMPAIGN;
    $wgNamespaceAliases['Campaign_talk'] = NS_CAMPAIGN_TALK;
    break;
  // other cases 
  default:
    $wgExtraNamespaces[NS_CAMPAIGN]      = "Campaign";
    $wgExtraNamespaces[NS_CAMPAIGN_TALK] = "Campaign_talk";
  break;
}

#############################
# Extension: UploadWizard & Co
#############################
wfLoadExtension( 'EventLogging' );
wfLoadExtension( 'UploadWizard' );

and it works as I want it to:

  1. it uses Medienkampagne on a German Wiki as default
  2. but Campaign also works (and is led to Medienkampagne)

I don’t know if it is the right way but it works for me ;-)