Index: trunk/extensions/LiveTranslate/includes/LT_TMUnit.php |
— | — | @@ -129,4 +129,15 @@ |
130 | 130 | return false; |
131 | 131 | } |
132 | 132 | |
| 133 | + /** |
| 134 | + * Returns the amount of languages (variants). |
| 135 | + * |
| 136 | + * @since 0.4 |
| 137 | + * |
| 138 | + * @return integer |
| 139 | + */ |
| 140 | + public function getLanguageAmount() { |
| 141 | + return count( $this->variants ); |
| 142 | + } |
| 143 | + |
133 | 144 | } |
Index: trunk/extensions/LiveTranslate/includes/LT_TranslationMemory.php |
— | — | @@ -51,4 +51,26 @@ |
52 | 52 | return $this->translationUnits; |
53 | 53 | } |
54 | 54 | |
| 55 | + /** |
| 56 | + * Returns the max amount of languages (variants) in a single translation unit. |
| 57 | + * Note: this might not be the total amount of unique languages! |
| 58 | + * |
| 59 | + * @since 0.4 |
| 60 | + * |
| 61 | + * @return integer |
| 62 | + */ |
| 63 | + public function getLanguageAmount() { |
| 64 | + $maxAmount = 0; |
| 65 | + |
| 66 | + foreach ( $this->translationUnits as $tu ) { |
| 67 | + $amount = $tu->getLanguageAmount(); |
| 68 | + |
| 69 | + if ( $amount > $maxAmount ) { |
| 70 | + $maxAmount = $amount; |
| 71 | + } |
| 72 | + } |
| 73 | + |
| 74 | + return $maxAmount; |
| 75 | + } |
| 76 | + |
55 | 77 | } |
Index: trunk/extensions/LiveTranslate/api/ApiImportTranslationMemories.php |
— | — | @@ -28,10 +28,6 @@ |
29 | 29 | $this->dieUsageMsg( array( 'missingparam', $requiredParam ) ); |
30 | 30 | } |
31 | 31 | } |
32 | | - |
33 | | - //if ( !$wgUser->isAllowed( 'managetms' ) ) { |
34 | | - // $this->dieUsageMsg( array( 'permissiondenied' ) ); |
35 | | - //} |
36 | 32 | |
37 | 33 | foreach ( $params['source'] as $location ) { |
38 | 34 | $text = false; |
— | — | @@ -89,7 +85,8 @@ |
90 | 86 | array( 'memory_id' => $memoryId ) |
91 | 87 | ); |
92 | 88 | |
93 | | - $wordId = ( $memoryId - 1 ) * 100000; |
| 89 | + $idOffset = ( $memoryId - 1 ) * 100000; |
| 90 | + $wordId = 0; |
94 | 91 | |
95 | 92 | $dbw->begin(); |
96 | 93 | |
— | — | @@ -106,7 +103,7 @@ |
107 | 104 | $dbw->insert( |
108 | 105 | 'live_translate', |
109 | 106 | array( |
110 | | - 'word_id' => $wordId, |
| 107 | + 'word_id' => $idOffset + $wordId, |
111 | 108 | 'word_language' => $this->cleanLanguage( $language ), |
112 | 109 | 'word_translation' => $translation, |
113 | 110 | 'word_primary' => $primary, |
— | — | @@ -125,6 +122,15 @@ |
126 | 123 | $dbw->begin(); |
127 | 124 | } |
128 | 125 | } |
| 126 | + |
| 127 | + $dbw->update( |
| 128 | + 'live_translate_memories', |
| 129 | + array( |
| 130 | + 'memory_lang_count' => $tm->getLanguageAmount(), |
| 131 | + 'memory_tu_count' => $wordId |
| 132 | + ), |
| 133 | + array( 'memory_id' => $memoryId ) |
| 134 | + ); |
129 | 135 | |
130 | 136 | $dbw->commit(); |
131 | 137 | } |
Index: trunk/extensions/LiveTranslate/LiveTranslate.sql |
— | — | @@ -14,7 +14,9 @@ |
15 | 15 | memory_id INT(4) unsigned NOT NULL auto_increment PRIMARY KEY, |
16 | 16 | memory_type INT(2) unsigned NOT NULL, |
17 | 17 | memory_location VARCHAR(255) NOT NULL, |
18 | | - memory_local INT(1) unsigned NOT NULL |
| 18 | + memory_local INT(1) unsigned NOT NULL, |
| 19 | + memory_lang_count INT(2) unsigned NOT NULL, |
| 20 | + memory_tu_count INT(8) unsigned NOT NULL |
19 | 21 | ) /*$wgDBTableOptions*/; |
20 | 22 | |
21 | | -INSERT INTO /*$wgDBprefix*/live_translate_memories VALUES (NULL, 0, "Live Translate Dictionary", 1); |
\ No newline at end of file |
| 23 | +INSERT INTO /*$wgDBprefix*/live_translate_memories VALUES (NULL, 0, "Live Translate Dictionary", 1, 0, 0); |
\ No newline at end of file |