![]() |
![]() |
![]() |
![]() |
![]() |
This is a simple idea to get a custom translated sidebar. I don't know how to do it in another way, so I thinked to put a patch in includes/Skin.php.
With this patch, the sidebar source pages with translations are accessible at Mediawiki:Sidebar-LANG, where LANG=en,de,it,etc. The patch is tested in 1.15.1.
# diff mw/includes/Skin.php mw-old/includes/Skin.php 1140c1140 < global $wgMemc, $wgEnableSidebarCache, $wgSidebarCacheExpiry; --- > global $wgMemc, $wgEnableSidebarCache, $wgSidebarCacheExpiry, $wgLang; 1143c1143,1153 < $key = wfMemcKey( 'sidebar', $this->getLanguage()->getCode() ); --- > //Insert patch here --> > $sidebar_name='sidebar' . '-' . $wgLang->getCode(); > > $sidebar_content = wfMsgForContent( $sidebar_name ); > if ( wfEmptyMsg ( $sidebar_name, $sidebar_content) ) { > $sidebar_name='sidebar'; > } > //End patch <-- > > // $key = wfMemcKey( 'sidebar', $this->getLanguage()->getCode() ); > $key = wfMemcKey( $sidebar_name, $this->getLanguage()->getCode() ); 1154c1164,1165 < $this->addToSidebar( $bar, 'sidebar' ); --- > // $this->addToSidebar( $bar, 'sidebar' ); > $this->addToSidebar( $bar, $sidebar_name );
Apply patch: add the code inside includes/Skin.php as shown below:
function buildSidebar() { global $parserMemc, $wgEnableSidebarCache, $wgSidebarCacheExpiry; global $wgLang; wfProfileIn( __METHOD__ ); $key = wfMemcKey( 'sidebar', $wgLang->getCode() ); if ( $wgEnableSidebarCache ) { $cachedsidebar = $parserMemc->get( $key ); if ( $cachedsidebar ) { wfProfileOut( __METHOD__ ); return $cachedsidebar; } } $bar = array(); //Insert patch here --> $sidebar_name='sidebar' . '-' . $wgLang->getCode(); $sidebar_content = wfMsgForContent( $sidebar_name ); if ( wfEmptyMsg ( $sidebar_name, $sidebar_content) ) { $sidebar_name='sidebar'; } //End patch <-- $lines = explode( "\n", wfMsgForContent( $sidebar_name ) );
Note:
You must install LanguageSelector extension. I've put same idea also here