Index: trunk/extensions/Translate/utils/TranslationHelpers.php |
— | — | @@ -211,6 +211,10 @@ |
212 | 212 | return (string) call_user_func( $all['check'] ); |
213 | 213 | } |
214 | 214 | |
| 215 | + if ( $this->group instanceof RecentMessageGroup ) { |
| 216 | + $all['last-diff'] = array( $this, 'getLastDiff' ); |
| 217 | + } |
| 218 | + |
215 | 219 | $boxes = array(); |
216 | 220 | foreach ( $all as $type => $cb ) { |
217 | 221 | $box = call_user_func( $cb ); |
— | — | @@ -981,6 +985,57 @@ |
982 | 986 | return $diff->getDiff( wfMsgHtml( 'tpt-diff-old' ), wfMsgHtml( 'tpt-diff-new' ) ); |
983 | 987 | } |
984 | 988 | |
| 989 | + protected function getLastDiff() { |
| 990 | + // Shortcuts |
| 991 | + $title = $this->title; |
| 992 | + $latestRevId = $title->getLatestRevID(); |
| 993 | + $previousRevId = $title->getPreviousRevisionID( $latestRevId ); |
| 994 | + |
| 995 | + $latestRev = Revision::newFromTitle( $title, $latestRevId ); |
| 996 | + $previousRev = Revision::newFromTitle( $title, $previousRevId ); |
| 997 | + |
| 998 | + $diffText = ''; |
| 999 | + |
| 1000 | + if ( $latestRev && $previousRev ) { |
| 1001 | + $latest = $latestRev->getText(); |
| 1002 | + $previous = $previousRev->getText(); |
| 1003 | + if ( $previous !== $latest ) { |
| 1004 | + $diff = new DifferenceEngine; |
| 1005 | + if ( method_exists( 'DifferenceEngine', 'setTextLanguage' ) ) { |
| 1006 | + $diff->setTextLanguage( $this->targetLanguage ); |
| 1007 | + } |
| 1008 | + $diff->setText( $previous, $latest ); |
| 1009 | + $diff->setReducedLineNumbers(); |
| 1010 | + $diff->showDiffStyle(); |
| 1011 | + $diffText = $diff->getDiff( false, false ); |
| 1012 | + } |
| 1013 | + } |
| 1014 | + |
| 1015 | + if ( !$latestRev ) { |
| 1016 | + return null; |
| 1017 | + } |
| 1018 | + |
| 1019 | + global $wgUser; |
| 1020 | + $user = $latestRev->getUserText( Revision::FOR_THIS_USER, $wgUser ); |
| 1021 | + $comment = $latestRev->getComment(); |
| 1022 | + |
| 1023 | + if ( $diffText === '' ) { |
| 1024 | + if ( strval( $comment ) !== '' ) { |
| 1025 | + $text = wfMessage( 'translate-dynagroup-byc', $user, $comment )->escaped(); |
| 1026 | + } else { |
| 1027 | + $text = wfMessage( 'translate-dynagroup-by', $user )->escaped(); |
| 1028 | + } |
| 1029 | + } else { |
| 1030 | + if ( strval( $comment ) !== '' ) { |
| 1031 | + $text = wfMessage( 'translate-dynagroup-lastc', $user, $comment )->escaped(); |
| 1032 | + } else { |
| 1033 | + $text = wfMessage( 'translate-dynagroup-last', $user )->escaped(); |
| 1034 | + } |
| 1035 | + } |
| 1036 | + |
| 1037 | + return TranslateUtils::fieldset( $text, $diffText, array( 'class' => 'mw-sp-translate-latestchange' ) ); |
| 1038 | + } |
| 1039 | + |
985 | 1040 | /** |
986 | 1041 | * @param $label string |
987 | 1042 | * @return string |
Index: trunk/extensions/Translate/Translate.i18n.php |
— | — | @@ -413,6 +413,11 @@ |
414 | 414 | 'translate-dynagroup-recent-label' => 'Recent translations', |
415 | 415 | 'translate-dynagroup-recent-desc' => 'This message group shows all recent translations into this language. |
416 | 416 | Most useful with Accept messages or Review all translations task.', |
| 417 | + |
| 418 | + 'translate-dynagroup-by' => 'Translation made by {{GENDER:$1|$1}}', |
| 419 | + 'translate-dynagroup-byc' => 'Translation made by {{GENDER:$1|$1}} ($2)', |
| 420 | + 'translate-dynagroup-last' => 'Latest change by {{GENDER:$1|$1}}', |
| 421 | + 'translate-dynagroup-lastc' => 'Latest change by {{GENDER:$1|$1}} ($2)', |
417 | 422 | ); |
418 | 423 | |
419 | 424 | /** Message documentation (Message documentation) |
Index: trunk/extensions/Translate/resources/ext.translate.quickedit.css |
— | — | @@ -88,3 +88,7 @@ |
89 | 89 | .mw-sp-translate-edit-warnings { background-color: #FFDBDB; } |
90 | 90 | .mw-translate-definition-preview { padding: 3px; } |
91 | 91 | .mw-translate-edit-tmsugs { background-color: #C0F9B6; } |
| 92 | + |
| 93 | +.mw-sp-translate-latestchange { |
| 94 | + padding-bottom: 0px; |
| 95 | +} |