Index: trunk/extensions/LiveTranslate/LiveTranslate.i18n.php |
— | — | @@ -34,6 +34,7 @@ |
35 | 35 | 'livetranslate-tmtype-ltf' => 'Live Translate format', |
36 | 36 | 'livetranslate-tmtype-tmx' => 'Translation Memory eXchange', |
37 | 37 | 'livetranslate-tmtype-gcsv' => 'Google CSV', |
| 38 | + 'livetranslate-special-no-tms-yet' => 'There are no translation memories yet.', |
38 | 39 | ); |
39 | 40 | |
40 | 41 | /** Belarusian (Taraškievica orthography) (Беларуская (тарашкевіца)) |
Index: trunk/extensions/LiveTranslate/specials/SpecialLiveTranslate.php |
— | — | @@ -76,7 +76,79 @@ |
77 | 77 | return; |
78 | 78 | } |
79 | 79 | |
80 | | - // TODO |
| 80 | + $this->displayTMConfig(); |
81 | 81 | } |
82 | 82 | |
| 83 | + /** |
| 84 | + * Displays the translation memories config table. |
| 85 | + * |
| 86 | + * @since 0.4 |
| 87 | + */ |
| 88 | + protected function displayTMConfig() { |
| 89 | + global $wgOut; |
| 90 | + |
| 91 | + $tms = $this->getTMConfigItems(); |
| 92 | + |
| 93 | + if ( count( $tms ) > 0 ) { |
| 94 | + foreach ( $tms as $tm ) { |
| 95 | + $this->displayTMItem( $tm ); |
| 96 | + } |
| 97 | + } |
| 98 | + else { |
| 99 | + $wgOut->addWikiMsg( 'livetranslate-special-no-tms-yet' ); |
| 100 | + } |
| 101 | + |
| 102 | + $this->displayAddNewTM(); |
| 103 | + } |
| 104 | + |
| 105 | + /** |
| 106 | + * Displays a single row in the translation memories config table. |
| 107 | + * |
| 108 | + * @since 0.4 |
| 109 | + * |
| 110 | + * @return array |
| 111 | + */ |
| 112 | + protected function getTMConfigItems() { |
| 113 | + $dbr = wfGetDB( DB_SLAVE ); |
| 114 | + |
| 115 | + $res = $dbr->select( |
| 116 | + 'live_translate_memories', |
| 117 | + array( 'memory_id', 'memory_type', 'memory_location' ), |
| 118 | + array(), |
| 119 | + __METHOD__, |
| 120 | + array( 'LIMIT' => '5000' ) |
| 121 | + ); |
| 122 | + |
| 123 | + $tms = array(); |
| 124 | + |
| 125 | + // Iterate over the result items in the result wrapper to end up with a regular array. |
| 126 | + foreach ( $res as $tm ) { |
| 127 | + $tms[] = $tm; |
| 128 | + } |
| 129 | + |
| 130 | + return $tms; |
| 131 | + } |
| 132 | + |
| 133 | + /** |
| 134 | + * Displays a single row in the translation memories config table. |
| 135 | + * |
| 136 | + * @since 0.4 |
| 137 | + * |
| 138 | + * @param object $tm |
| 139 | + */ |
| 140 | + protected function displayTMItem( $tm ) { |
| 141 | + global $wgOut; |
| 142 | + |
| 143 | + |
| 144 | + } |
| 145 | + |
| 146 | + /** |
| 147 | + * Displays an input to add a new translation memory. |
| 148 | + * |
| 149 | + * @since 0.4 |
| 150 | + */ |
| 151 | + protected function displayAddNewTM() { |
| 152 | + |
| 153 | + } |
| 154 | + |
83 | 155 | } |