Index: includes/filerepo/file/File.php
===================================================================
--- includes/filerepo/file/File.php	(revision 105891)
+++ includes/filerepo/file/File.php	(working copy)
@@ -836,7 +836,8 @@
 			$path = '/common/images/icons/' . $icon;
 			$filepath = $wgStyleDirectory . $path;
 			if( file_exists( $filepath ) ) {
-				return new ThumbnailImage( $this, $wgStylePath . $path, 120, 120 );
+				$params = array( 'height' => 120, 'width' => '120' );
+				return new ThumbnailImage( $this, $wgStylePath . $path, $params );
 			}
 		}
 		return null;
Index: includes/ImagePage.php
===================================================================
--- includes/ImagePage.php	(revision 105891)
+++ includes/ImagePage.php	(working copy)
@@ -291,6 +291,10 @@
 			} else {
 				$params = array( 'page' => $page );
 			}
+			$lang = $wgRequest->getVal( 'lang' );
+			if ( !is_null( $lang ) ) {
+				$params['lang'] = $lang;
+			}
 			$width_orig = $this->displayImg->getWidth( $page );
 			$width = $width_orig;
 			$height_orig = $this->displayImg->getHeight( $page );
Index: includes/media/Bitmap.php
===================================================================
--- includes/media/Bitmap.php	(revision 105891)
+++ includes/media/Bitmap.php	(working copy)
@@ -203,8 +203,7 @@
 		} elseif ( $mto ) {
 			return $mto;
 		} else {
-			return new ThumbnailImage( $image, $dstUrl, $scalerParams['clientWidth'],
-				$scalerParams['clientHeight'], $dstPath );
+			return new ThumbnailImage( $image, $dstUrl, $params, $dstPath );
 		}
 	}
 
Index: includes/media/Bitmap_ClientOnly.php
===================================================================
--- includes/media/Bitmap_ClientOnly.php	(revision 105891)
+++ includes/media/Bitmap_ClientOnly.php	(working copy)
@@ -37,7 +37,6 @@
 		if ( !$this->normaliseParams( $image, $params ) ) {
 			return new TransformParameterError( $params );
 		}
-		return new ThumbnailImage( $image, $image->getURL(), $params['width'], 
-			$params['height'], $image->getPath() );
+		return new ThumbnailImage( $image, $image->getURL(), $params, $image->getPath() );
 	}
 }
Index: includes/media/DjVu.php
===================================================================
--- includes/media/DjVu.php	(revision 105891)
+++ includes/media/DjVu.php	(working copy)
@@ -129,20 +129,17 @@
 		if ( !$this->normaliseParams( $image, $params ) ) {
 			return new TransformParameterError( $params );
 		}
-		$width = $params['width'];
-		$height = $params['height'];
 		$srcPath = $image->getPath();
-		$page = $params['page'];
 		if ( $page > $this->pageCount( $image ) ) {
-			return new MediaTransformError( 'thumbnail_error', $width, $height, wfMsg( 'djvu_page_error' ) );
+			return new MediaTransformError( 'thumbnail_error', $params['width'], $params['height'], wfMsg( 'djvu_page_error' ) );
 		}
 
 		if ( $flags & self::TRANSFORM_LATER ) {
-			return new ThumbnailImage( $image, $dstUrl, $width, $height, $dstPath, $page );
+			return new ThumbnailImage( $image, $dstUrl, $params, $dstPath );
 		}
 
 		if ( !wfMkdirParents( dirname( $dstPath ), null, __METHOD__ ) ) {
-			return new MediaTransformError( 'thumbnail_error', $width, $height, wfMsg( 'thumbnail_dest_directory' ) );
+			return new MediaTransformError( 'thumbnail_error', $params['width'], $params['height'], wfMsg( 'thumbnail_dest_directory' ) );
 		}
 
 		# Use a subshell (brackets) to aggregate stderr from both pipeline commands
@@ -165,9 +162,9 @@
 			wfDebugLog( 'thumbnail',
 				sprintf( 'thumbnail failed on %s: error %d "%s" from "%s"',
 					wfHostname(), $retval, trim($err), $cmd ) );
-			return new MediaTransformError( 'thumbnail_error', $width, $height, $err );
+			return new MediaTransformError( 'thumbnail_error', $params['width'], $params['height'], $err );
 		} else {
-			return new ThumbnailImage( $image, $dstUrl, $width, $height, $dstPath, $page );
+			return new ThumbnailImage( $image, $dstUrl, $params, $dstPath );
 		}
 	}
 
Index: includes/media/Generic.php
===================================================================
--- includes/media/Generic.php	(revision 105891)
+++ includes/media/Generic.php	(working copy)
@@ -691,10 +691,9 @@
 			return false;
 		}
 		$url = $script . '&' . wfArrayToCGI( $this->getScriptParams( $params ) );
-		$page = isset( $params['page'] ) ? $params['page'] : false;
 
 		if( $image->mustRender() || $params['width'] < $image->getWidth() ) {
-			return new ThumbnailImage( $image, $url, $params['width'], $params['height'], $page );
+			return new ThumbnailImage( $image, $url, $params );
 		}
 	}
 
Index: includes/media/MediaTransformOutput.php
===================================================================
--- includes/media/MediaTransformOutput.php	(revision 105891)
+++ includes/media/MediaTransformOutput.php	(working copy)
@@ -17,7 +17,7 @@
 	 */
 	var $file;
 
-	var $width, $height, $url, $page, $path;
+	var $width, $height, $url, $page, $path, $lang;
 
 	/**
 	 * Get the width of the output box
@@ -99,6 +99,12 @@
 	 */
 	function getDescLinkAttribs( $title = null, $params = '' ) {
 		$query = $this->page ? ( 'page=' . urlencode( $this->page ) ) : '';
+		if( $this->lang ){
+			if( $query ){
+				$query .= '&';
+			}
+			$query .=  'lang=' . urlencode( $this->lang );
+		}
 		if( $params ) {
 			$query .= $query ? '&'.$params : $params;
 		}
@@ -123,22 +129,21 @@
 	/**
 	 * @param $file File object
 	 * @param $url String: URL path to the thumb
-	 * @param $width Integer: file's width
-	 * @param $height Integer: file's height
+	 * @param $params
 	 * @param $path String: filesystem path to the thumb
-	 * @param $page Integer: page number, for multipage files
 	 * @private
 	 */
-	function __construct( $file, $url, $width, $height, $path = false, $page = false ) {
+	function __construct( $file, $url, $params, $path = false ) {
 		$this->file = $file;
 		$this->url = $url;
 		# These should be integers when they get here.
 		# If not, there's a bug somewhere.  But let's at
 		# least produce valid HTML code regardless.
-		$this->width = round( $width );
-		$this->height = round( $height );
+		$this->width = isset( $params['width'] ) ? round( $params['width'] ) : null;
+		$this->height = isset( $params['height'] ) ? round( $params['height'] ) : null;
+		$this->page = isset( $params['page'] ) ? $params['page'] : false;
+		$this->lang = isset( $params['lang'] ) ? $params['lang'] : false;
 		$this->path = $path;
-		$this->page = $page;
 	}
 
 	/**
Index: includes/media/SVG.php
===================================================================
--- includes/media/SVG.php	(revision 105891)
+++ includes/media/SVG.php	(working copy)
@@ -89,14 +89,12 @@
 		if ( !$this->normaliseParams( $image, $params ) ) {
 			return new TransformParameterError( $params );
 		}
-		$clientWidth = $params['width'];
-		$clientHeight = $params['height'];
 		$physicalWidth = $params['physicalWidth'];
 		$physicalHeight = $params['physicalHeight'];
 		$srcPath = $image->getPath();
 
 		if ( $flags & self::TRANSFORM_LATER ) {
-			return new ThumbnailImage( $image, $dstUrl, $clientWidth, $clientHeight, $dstPath );
+			return new ThumbnailImage( $image, $dstUrl, $params, $dstPath );
 		}
 
 		if ( !wfMkdirParents( dirname( $dstPath ), null, __METHOD__ ) ) {
@@ -104,9 +102,9 @@
 				wfMsg( 'thumbnail_dest_directory' ) );
 		}
 
-		$status = $this->rasterize( $srcPath, $dstPath, $physicalWidth, $physicalHeight );
+		$status = $this->rasterize( $srcPath, $dstPath, $physicalWidth, $physicalHeight, $language );
 		if( $status === true ) {
-			return new ThumbnailImage( $image, $dstUrl, $clientWidth, $clientHeight, $dstPath );
+			return new ThumbnailImage( $image, $dstUrl, $params, $dstPath );
 		} else {
 			return $status; // MediaTransformError
 		}
@@ -121,7 +119,7 @@
 	* @param string $height
 	* @return true|MediaTransformError
 	*/
-	public function rasterize( $srcPath, $dstPath, $width, $height ) {
+	public function rasterize( $srcPath, $dstPath, $width, $height, $language = false ) {
 		global $wgSVGConverters, $wgSVGConverter, $wgSVGConverterPath;
 		$err = false;
 		$retval = '';
@@ -129,7 +127,7 @@
 			if ( is_array( $wgSVGConverters[$wgSVGConverter] ) ) {
 				// This is a PHP callable
 				$func = $wgSVGConverters[$wgSVGConverter][0];
-				$args = array_merge( array( $srcPath, $dstPath, $width, $height ),
+				$args = array_merge( array( $srcPath, $dstPath, $width, $height, $language ),
 					array_slice( $wgSVGConverters[$wgSVGConverter], 1 ) );
 				if ( !is_callable( $func ) ) {
 					throw new MWException( "$func is not callable" );
@@ -147,9 +145,13 @@
 						   wfEscapeShellArg( $dstPath ) ),
 					$wgSVGConverters[$wgSVGConverter]
 				) . " 2>&1";
+				$env = array();
+				if( $language !== false){				
+					$env['LANG'] = $language;
+				}
 				wfProfileIn( 'rsvg' );
 				wfDebug( __METHOD__.": $cmd\n" );
-				$err = wfShellExec( $cmd, $retval );
+				$err = wfShellExec( $cmd, $retval, $env );
 				wfProfileOut( 'rsvg' );
 			}
 		}
@@ -162,7 +164,7 @@
 		return true;
 	}
 
-	public static function rasterizeImagickExt( $srcPath, $dstPath, $width, $height ) {
+	public static function rasterizeImagickExt( $srcPath, $dstPath, $width, $height, $language ) {
 		$im = new Imagick( $srcPath );
 		$im->setImageFormat( 'png' );
 		$im->setBackgroundColor( 'transparent' );
@@ -295,4 +297,64 @@
 		}
 		return $result;
 	}
+	
+	/**
+	 * @param string $name Parameter name
+	 * @param $string $value Parameter value
+	 * @return bool Validity
+	 */
+	function validateParam( $name, $value ){
+		if ( in_array( $name, array( 'width', 'height' ) ) ) {
+			if ( $value <= 0 ) {
+				return false;
+			} else {
+				return true;
+			}
+		} else if( $name == 'lang' ){
+			# Validate $code
+			$languages = Language::getLanguageNames();
+			if( !isset( $languages[$value] ) ) {
+				wfDebug( "Invalid user language code\n" );
+				return false;
+			}
+			return true;			
+		} else {
+			return false;
+		}
+	}
+	
+	/**
+	 * @param array $params name=>value pairs of parameters
+	 * @return string Filename to use
+	 */
+	function makeParamString( $params ){
+	 	$lang = isset( $params['lang'] ) ? "lang{$params['lang']}-" : "";
+	 	if ( !isset( $params['width'] ) ) {
+			return false;
+	 	}
+	 	return "$lang{$params['width']}px";
+	}
+	
+	function parseParamString( $str ) {
+		$m = false;
+		if ( preg_match( '/^lang([a-z]+(?:-[a-z]+)*)-(\d+)px$/', $str, $m ) ) {
+			return array( 'width' => $m[2], 'lang' => $m[1] );
+		} else {
+			return false;
+		}
+   	}
+
+	function getParamMap(){
+		return array( 'img_lang' => 'lang', 'img_width' => 'width' );
+	}
+	/**
+	 * @param $params
+	 * @return array
+	 */
+	function getScriptParams( $params ) {
+		return array(
+			'width' => $params['width'],
+			'lang' => $params['lang'],
+		);
+	}
 }
Index: languages/messages/MessagesEn.php
===================================================================
--- languages/messages/MessagesEn.php	(revision 105891)
+++ languages/messages/MessagesEn.php	(working copy)
@@ -267,6 +267,7 @@
 	'img_center'             => array( 1,    'center', 'centre'       ),
 	'img_framed'             => array( 1,    'framed', 'enframed', 'frame' ),
 	'img_frameless'          => array( 1,    'frameless'              ),
+	'img_lang'               => array( 1,    'lang=$1'	              ),
 	'img_page'               => array( 1,    'page=$1', 'page $1'     ),
 	'img_upright'            => array( 1,    'upright', 'upright=$1', 'upright $1'  ),
 	'img_border'             => array( 1,    'border'                 ),
