https://bugzilla.wikimedia.org/show_bug.cgi?id=46372
Web browser: ---
Bug ID: 46372
Summary: {{CONTENTLANGUAGE}} doesn't show the selected language
Product: MediaWiki extensions
Version: REL1_20 branch
Hardware: All
OS: All
Status: UNCONFIRMED
Severity: enhancement
Priority: Unprioritized
Component: UniversalLanguageSelector
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected],
[email protected], [email protected],
[email protected], [email protected],
[email protected],
[email protected]
Classification: Unclassified
Mobile Platform: ---
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 :-)
--
You are receiving this mail because:
You are on the CC list for the bug.
You are the assignee for the bug.
You are watching all bug changes.
_______________________________________________
Wikibugs-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikibugs-l