r89948 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r89947‎ | r89948 | r89949 >
Date:07:47, 13 June 2011
Author:nikerabbit
Status:ok (Comments)
Tags:
Comment:
* Fix I18nTags #languagename to use ParserOptions::getUserLang()
* Fix ParserOptions::getUserLang() to return code as documented
Modified paths:
  • /trunk/extensions/I18nTags/I18nTags_body.php (modified) (history)
  • /trunk/phase3/includes/parser/ParserOptions.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/parser/ParserOptions.php
@@ -114,6 +114,8 @@
115115 * You shouldn't use this. Really. $parser->getFunctionLang() is all you need.
116116 * Using this fragments the cache and is discouraged. Yes, {{int: }} uses this,
117117 * producing inconsistent tables (Bug 14404).
 118+ * @return String Language code
 119+ * @since 1.17
118120 */
119121 function getUserLang() {
120122 $this->optionUsed('userlang');
@@ -143,7 +145,12 @@
144146 function setCleanSignatures( $x ) { return wfSetVar( $this->mCleanSignatures, $x ); }
145147 function setExternalLinkTarget( $x ) { return wfSetVar( $this->mExternalLinkTarget, $x ); }
146148 function setMath( $x ) { return wfSetVar( $this->mMath, $x ); }
147 - function setUserLang( $x ) { return wfSetVar( $this->mUserLang, $x ); }
 149+ function setUserLang( $x ) {
 150+ if ( $x instanceof Language ) {
 151+ $x = $x->getCode();
 152+ }
 153+ return wfSetVar( $this->mUserLang, $x );
 154+ }
148155 function setThumbSize( $x ) { return wfSetVar( $this->mThumbSize, $x ); }
149156 function setStubThreshold( $x ) { return wfSetVar( $this->mStubThreshold, $x ); }
150157 function setPreSaveTransform( $x ) { return wfSetVar( $this->mPreSaveTransform, $x ); }
Index: trunk/extensions/I18nTags/I18nTags_body.php
@@ -58,7 +58,7 @@
5959 return '';
6060 }
6161 if ( !$outputLanguage ) {
62 - $outputLanguage = $wgLang->getCode();
 62+ $outputLanguage = $parser->getOptions()->getUserLang();
6363 }
6464 $cldr = is_callable( array( 'LanguageNames', 'getNames' ));
6565 if ( $outputLanguage !== 'native' && $cldr ) {

Comments

#Comment by Platonides (talk | contribs)   20:01, 14 June 2011

You weren't supposed to pass setUserLang() a Language object. Maybe it should thrown an exception instead of doing the right thing. Passing setUserLang() an object and getting a Language code is also weird...

#Comment by Nikerabbit (talk | contribs)   20:05, 14 June 2011

This was just a quick fix. Feel free to replace with a better one.

#Comment by Platonides (talk | contribs)   17:02, 16 June 2011

Actually, I think there was some code down at wfMsg* so that both may have worked.

#Comment by Nikerabbit (talk | contribs)   19:56, 16 June 2011

What both would have worked?

#Comment by Platonides (talk | contribs)   20:40, 16 June 2011

Passing either a language code or a language object.

#Comment by Nikerabbit (talk | contribs)   20:45, 16 June 2011

Yeah, but the CLDR didn't like objects.

Status & tagging log