r80198 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r80197‎ | r80198 | r80199 >
Date:22:33, 13 January 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Modified translation directory pages to display stats from the db and link to the LT special
Modified paths:
  • /trunk/extensions/LiveTranslate/LiveTranslate.hooks.php (modified) (history)
  • /trunk/extensions/LiveTranslate/LiveTranslate.i18n.php (modified) (history)

Diff [purge]

Index: trunk/extensions/LiveTranslate/LiveTranslate.i18n.php
@@ -28,6 +28,7 @@
2929 'livetranslate-dictionary-empty' => 'There are no words in the dictionary yet. Click the "edit" tab to add some.',
3030 'livetranslate-dictionary-count' => 'There {{PLURAL:$1|is $1 word|are $1 words}} in $2 {{PLURAL:$2|language|languages}}. Click the "edit" tab to add more.',
3131 'livetranslate-dictionary-unallowed-langs' => '{{PLURAL:$2|This language is|These languages are}} not currently set as allowed translation target: $1. Modify the allowed languages in your wikis configuration, or remove these from the dictionary.',
 32+ 'livetranslate-dictionary-goto-edit' => 'Modify the translation memories.',
3233
3334 // Special:LiveTranslate
3435 'special-livetranslate' => 'Live translate',
Index: trunk/extensions/LiveTranslate/LiveTranslate.hooks.php
@@ -13,8 +13,8 @@
1414 final class LiveTranslateHooks {
1515
1616 /**
 17+ * Hook to insert things into article headers.
1718 *
18 - *
1919 * @since 0.1
2020 *
2121 * @param Article &$article
@@ -55,22 +55,45 @@
5656 * @param Title $title
5757 */
5858 protected static function displayDictionaryPage( Article &$article, Title $title ) {
59 - global $wgOut, $wgLang, $egLiveTranslateLanguages;
 59+ global $wgOut, $wgLang, $wgUser, $egLiveTranslateLanguages;
6060
61 - $parser = LTTMParser::newFromType( LiveTranslateFunctions::getMemoryType( $title->getFullText() ) );
62 - $tm = $parser->parse( $article->getContent() );
63 - $tus = $tm->getTranslationUnits();
 61+ $dbr = wfGetDb( DB_SLAVE );
6462
65 - if ( count( $tus ) == 0 ) {
 63+ $res = $dbr->select(
 64+ 'live_translate_memories',
 65+ array(
 66+ 'memory_lang_count',
 67+ 'memory_tu_count'
 68+ ),
 69+ array( 'memory_location' => $title->getFullText() ),
 70+ array( 'LIMIT' => 1 )
 71+ );
 72+
 73+ foreach ( $res as $tm ) {
 74+ break;
 75+ }
 76+
 77+ if ( $tm->memory_tu_count == 0 ) {
6678 $wgOut->addWikiMsg( 'livetranslate-dictionary-empty' );
6779 }
6880 else {
6981 $wgOut->addWikiMsg(
7082 'livetranslate-dictionary-count',
71 - $wgLang->formatNum( count( $tus ) ) ,
72 - $wgLang->formatNum( count( $tus[0]->getVariants() ) )
 83+ $wgLang->formatNum( $tm->memory_tu_count ) ,
 84+ $wgLang->formatNum( $tm->memory_lang_count )
7385 );
7486
 87+ if ( $wgUser->isAllowed( 'managetms' ) ) {
 88+ $wgOut->addHTML(
 89+ Html::element(
 90+ 'a',
 91+ array( 'href' => Title::newFromText( 'Special:LiveTranslate' )->getInternalURL() ),
 92+ wfMsg( 'livetranslate-dictionary-goto-edit' )
 93+ )
 94+ );
 95+ }
 96+
 97+ /*
7598 $notAllowedLanguages = array();
7699
77100 foreach ( $tus[0]->getVariants() as $languageCode => $translations ) {
@@ -103,6 +126,7 @@
104127 )
105128 );
106129 }
 130+ */
107131 }
108132 }
109133

Status & tagging log