Last modified: 2013-03-20 17:53:05 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T48372, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 46372 - {{CONTENTLANGUAGE}} doesn't show the selected language
{{CONTENTLANGUAGE}} doesn't show the selected language
Status: RESOLVED DUPLICATE of bug 2085
Product: MediaWiki extensions
Classification: Unclassified
UniversalLanguageSelector (Other open bugs)
master
All All
: Unprioritized enhancement (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-03-20 17:36 UTC by ziggy
Modified: 2013-03-20 17:53 UTC (History)
9 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description ziggy 2013-03-20 17:36:52 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 :-)
Comment 1 Nemo 2013-03-20 17:53:05 UTC
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 ***

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links