Tutorials/Hacking MediaWiki/Namespaces for languages

From ThorstensHome
Jump to: navigation, search


Scenario
You want your mediawiki installation to have articles in different languages. You want that by default, your users only see articles in their browser's language.
Solution
$wgNamespacesToBeSearchedDefault = array(
        NS_MAIN           => true,
        100               => true
);
if (strpos($_SERVER['HTTP_ACCEPT_LANGUAGE'],"de")===false)
{
  $wgNamespacesToBeSearchedDefault[100]=false;
}
  • start your firefox (in this tutorial we assume it is 3.0.10), add "German" (de) under Edit=>Preferences=>Content=>Languages
  • LOG OUT from your wiki to get rid of the search user preferences
  • go to your wiki and click on "search". Verify "DE" is tagged.
  • remove "German" (de) under Edit=>Preferences=>Content=>Languages
  • go to your wiki and click on "search". Verify "DE" is not tagged.