Last modified: 2013-03-20 17:53:05 UTC
The magic word {{CONTENTLANGUAGE}} doesn't show the selected language, and therefore it cannot be used to create templates that will display text according to the language selected. I've created a new magic word as part of my copy of UniversalLanguageSelector that may be of use to others, or even included in further releases: {{CURRENTUNILANGUAGE}} New UniversalLanguageSelector.i18n.magic.php file: $magicWords = array(); $magicWords['en'] = array('currentunilanguage' => array(0, 'CURRENTUNILANGUAGE')); Added to UniversalLanguageSelector.php, below last hook: $wgHooks['ParserGetVariableValueSwitch'][] = 'UniversalLanguageSelectorHooks::getLanguageMagic'; $wgHooks['MagicWordwgVariableIDs'][] = 'UniversalLanguageSelectorHooks::getLanguageMagicDeclareVarIds'; Added to UniversalLanguageSelector.hooks.php, above getLanguage(...): public static function getLanguageMagicDeclareVarIds( &$customVariableIds ) { $customVariableIds[] = 'currentunilanguage'; return true; } public static function getLanguageMagic(&$parser, &$cache, &$magicWordId, &$ret ) { if ( 'currentunilanguage' == $magicWordId ) { $context = RequestContext::getMain(); $code = $context->getLanguage()->getCode(); $ret = self::getLanguage($context->getUser(), $code) ? $code : ''; } return true; } Works like charm :-)
Thanks. This request has already been filed before, see the previous report for more details. (Doesn't even need to be done in ULS, "translatewiki.net magic" local extension/hack also provides it.) *** This bug has been marked as a duplicate of bug 2085 ***