Index: trunk/extensions/LiveTranslate/LiveTranslate.i18n.php |
— | — | @@ -28,6 +28,7 @@ |
29 | 29 | 'livetranslate-dictionary-empty' => 'There are no words in the dictionary yet. Click the "edit" tab to add some.', |
30 | 30 | '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.', |
31 | 31 | '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.', |
32 | 33 | |
33 | 34 | // Special:LiveTranslate |
34 | 35 | 'special-livetranslate' => 'Live translate', |
Index: trunk/extensions/LiveTranslate/LiveTranslate.hooks.php |
— | — | @@ -13,8 +13,8 @@ |
14 | 14 | final class LiveTranslateHooks { |
15 | 15 | |
16 | 16 | /** |
| 17 | + * Hook to insert things into article headers. |
17 | 18 | * |
18 | | - * |
19 | 19 | * @since 0.1 |
20 | 20 | * |
21 | 21 | * @param Article &$article |
— | — | @@ -55,22 +55,45 @@ |
56 | 56 | * @param Title $title |
57 | 57 | */ |
58 | 58 | protected static function displayDictionaryPage( Article &$article, Title $title ) { |
59 | | - global $wgOut, $wgLang, $egLiveTranslateLanguages; |
| 59 | + global $wgOut, $wgLang, $wgUser, $egLiveTranslateLanguages; |
60 | 60 | |
61 | | - $parser = LTTMParser::newFromType( LiveTranslateFunctions::getMemoryType( $title->getFullText() ) ); |
62 | | - $tm = $parser->parse( $article->getContent() ); |
63 | | - $tus = $tm->getTranslationUnits(); |
| 61 | + $dbr = wfGetDb( DB_SLAVE ); |
64 | 62 | |
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 ) { |
66 | 78 | $wgOut->addWikiMsg( 'livetranslate-dictionary-empty' ); |
67 | 79 | } |
68 | 80 | else { |
69 | 81 | $wgOut->addWikiMsg( |
70 | 82 | '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 ) |
73 | 85 | ); |
74 | 86 | |
| 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 | + /* |
75 | 98 | $notAllowedLanguages = array(); |
76 | 99 | |
77 | 100 | foreach ( $tus[0]->getVariants() as $languageCode => $translations ) { |
— | — | @@ -103,6 +126,7 @@ |
104 | 127 | ) |
105 | 128 | ); |
106 | 129 | } |
| 130 | + */ |
107 | 131 | } |
108 | 132 | } |
109 | 133 | |