From 93f0ae4eed584c9bb54fac26944f87b3ee0c14f4 Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Wed, 8 Feb 2006 22:56:55 +0000 Subject: [PATCH] Bug 4916: Make localised text (notably the word "line") work with the diff cache. Doing it this way means it will work with the external diff engine as well. --- includes/DifferenceEngine.php | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/includes/DifferenceEngine.php b/includes/DifferenceEngine.php index a69c505c20..5a4954a696 100644 --- a/includes/DifferenceEngine.php +++ b/includes/DifferenceEngine.php @@ -326,6 +326,7 @@ CONTROL; $difftext = $wgMemc->get( $key ); if ( $difftext ) { wfIncrStats( 'diff_cache_hit' ); + $difftext = $this->localiseLineNumbers( $difftext ); $difftext .= "\n\n"; return $difftext; } @@ -362,9 +363,24 @@ CONTROL; } else { wfIncrStats( 'diff_uncacheable' ); } + // Replace line numbers with the text in the user's language + $difftext = $this->localiseLineNumbers( $difftext ); return $difftext; } + /** + * Replace line numbers with the text in the user's language + */ + function localiseLineNumbers( $text ) { + return preg_replace_callback( '//', + array( &$this, 'localiseLineNumbersCb' ), $text ); + } + + function localiseLineNumbersCb( $matches ) { + global $wgLang; + return wfMsg( 'lineno', $wgLang->formatNum( $matches[1] ) ); + } + /** * Add the header to a diff body */ @@ -1601,11 +1617,8 @@ class TableDiffFormatter extends DiffFormatter } function _block_header( $xbeg, $xlen, $ybeg, $ylen ) { - $l1 = wfMsg( 'lineno', $xbeg ); - $l2 = wfMsg( 'lineno', $ybeg ); - - $r = ''.$l1."\n" . - ''.$l2."\n"; + $r = '\n" . + '\n"; return $r; } -- 2.20.1