r103786 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r103785‎ | r103786 | r103787 >
Date:21:27, 20 November 2011
Author:bawolff
Status:ok (Comments)
Tags:
Comment:
(bug 27793) Make a config variable ($wgBabelUseUserLanguage) to make the "Babel user language" header and "Users by language" footer be in user language instead of page/content language.

This feature is intended to be used on commons.
Modified paths:
  • /trunk/extensions/Babel/Babel.class.php (modified) (history)
  • /trunk/extensions/Babel/Babel.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Babel/Babel.class.php
@@ -19,6 +19,7 @@
2020 * @return string: Babel tower.
2121 */
2222 public static function Render( $parser ) {
 23+ global $wgBabelUseUserLanguage;
2324 $parameters = func_get_args();
2425 array_shift( $parameters );
2526 self::$title = $parser->getTitle();
@@ -56,7 +57,13 @@
5758 }
5859 }
5960
60 - $top = wfMessage( 'babel', self::$title->getDBkey() )->inContentLanguage(); // TODO: allow user language
 61+ $top = wfMessage( 'babel', self::$title->getDBkey() )->inContentLanguage();
 62+ if ( $wgBabelUseUserLanguage ) {
 63+ $top = $top->inLanguage( $parser->getOptions()->getUserLangObj() );
 64+ } else {
 65+ $top = $top->inContentLanguage();
 66+ }
 67+
6168 if ( $top->isDisabled() ) {
6269 $top = '';
6370 } else {
@@ -67,7 +74,13 @@
6875 }
6976 $top = '! class="mw-babel-header" | ' . $top;
7077 }
71 - $footer = wfMessage( 'babel-footer', self::$title->getDBkey() )->inContentLanguage(); // TODO: allow user language
 78+ $footer = wfMessage( 'babel-footer', self::$title->getDBkey() );
 79+ if ( $wgBabelUseUserLanguage ) {
 80+ $footer = $footer->inLanguage( $parser->getOptions()->getUserLangObj() );
 81+ } else {
 82+ $footer = $footer->inContentLanguage();
 83+ }
 84+
7285 $url = wfMessage( 'babel-footer-url' )->inContentLanguage();
7386 $showfooter = '';
7487 if ( !$footer->isDisabled() && !$url->isDisabled() ) {
Index: trunk/extensions/Babel/Babel.php
@@ -67,6 +67,9 @@
6868 $wgBabelMainCategory = '%code%';
6969 // Default level.
7070 $wgBabelDefaultLevel = 'N';
 71+// Use the viewing user's language for babel box header's and footer's
 72+// May fragment parser cache, but otherwise shouldn't cause problems
 73+$wgBabelUseUserLanguage = false;
7174 // A boolean (true or false) indicating whether ISO 639-3 codes should be preferred over ISO 639-1 codes.
7275 $wgBabelPreferISO639_3 = false; // Not yet used.
7376

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r82967bug 27793 - Babel box header shows link anchor text in user language, and lin...purodha21:33, 28 February 2011

Comments

#Comment by Nikerabbit (talk | contribs)   11:59, 7 December 2011

Should we even enable this by default? Most of the users are small wikies which don't see any performance hit. Heck, if WMF doesn't need to disable it, we could do it unconditionally.

#Comment by Bawolff (talk | contribs)   13:53, 7 December 2011

I mostly had it disabled by default because it seemed controversial based on r82967.

Status & tagging log