https://bugzilla.wikimedia.org/show_bug.cgi?id=2085

--- Comment #27 from PiRSquared17 <pirsquare...@gmail.com> ---
(In reply to ziggy from comment #26)
> For those who'd like this feature, I've hacked a new magic word as part of
> my copy of UniversalLanguageSelector: {{USERLANG}}
> 
> New UniversalLanguageSelector.i18n.magic.php file:
> $magicWords = array();
> $magicWords['en'] = array('userlang' => array(0,'USERLANG'));
> 
> 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[] = 'userlang'; return true; }
> public static function getLanguageMagic(&$parser, &$cache, &$magicWordId,
> &$ret
> ) { if ( 'userlang' == $magicWordId ) {
>       $context = RequestContext::getMain();
>       $code = $context->getLanguage()->getCode();
>       $ret = self::getLanguage($context->getUser(), $code) ? $code : '';
>       if($ret != $wgLanguageCode) $parser->disableCache(); }
>     return true; } 
> 
> 
> Works like charm, although heeding the warnings of the previous posters the
> cache gets disabled if the userlang is different than the wgLanguageCode :-)
> It now behaves very much like the dynamic results obtained from a database
> (e.g. WikiDB)

Could you please commit this to Gerrit?

-- 
You are receiving this mail because:
You are the assignee for the bug.
You are on the CC list for the bug.
_______________________________________________
Wikibugs-l mailing list
Wikibugs-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikibugs-l

Reply via email to