Index: trunk/extensions/LiveTranslate/includes/ext.livetranslate.js |
— | — | @@ -187,7 +187,7 @@ |
188 | 188 | * @param {string} targetLang |
189 | 189 | */ |
190 | 190 | function requestGoogleTranslate( sourceLang, targetLang ) { |
191 | | - translateElement( $( '#bodyContent' ), sourceLang, targetLang ); |
| 191 | + //translateElement( $( '#bodyContent' ), sourceLang, targetLang ); |
192 | 192 | } |
193 | 193 | |
194 | 194 | /** |
Index: trunk/extensions/LiveTranslate/includes/LT_TMXParser.php |
— | — | @@ -125,7 +125,7 @@ |
126 | 126 | break; |
127 | 127 | case 'tuv': |
128 | 128 | if ( array_key_exists( 'xml:lang', $attribs ) ) { |
129 | | - $this->currentLanguage = strtolower( $attribs['xml:lang'] ); |
| 129 | + $this->currentLanguage = $attribs['xml:lang']; |
130 | 130 | } |
131 | 131 | else { |
132 | 132 | // TODO: ignore node or give warning |
Index: trunk/extensions/LiveTranslate/includes/LiveTranslate_Functions.php |
— | — | @@ -291,6 +291,34 @@ |
292 | 292 | } |
293 | 293 | |
294 | 294 | /** |
| 295 | + * Returns an array with mapping from input language codes to MediaWiki language codes. |
| 296 | + * |
| 297 | + * @since 0.4 |
| 298 | + * |
| 299 | + * @return array |
| 300 | + */ |
| 301 | + public static function getInputLangMapping() { |
| 302 | + return array( |
| 303 | + 'en-us' => 'en', |
| 304 | + 'en' => 'en-gb', |
| 305 | + ); |
| 306 | + } |
| 307 | + |
| 308 | + /** |
| 309 | + * Returns an array with mapping from MediaWiki language codes to Google Translate language codes. |
| 310 | + * |
| 311 | + * @since 0.4 |
| 312 | + * |
| 313 | + * @return array |
| 314 | + */ |
| 315 | + public static function getOuputLangMapping() { |
| 316 | + return array( |
| 317 | + 'en-us' => 'en', |
| 318 | + 'en-gb' => 'en', |
| 319 | + ); |
| 320 | + } |
| 321 | + |
| 322 | + /** |
295 | 323 | * Returns the provided text starting with a letter in toggeled case. |
296 | 324 | * If there is no difference between lowercase and upercase for the first |
297 | 325 | * character, false is returned. |
Index: trunk/extensions/LiveTranslate/api/ApiImportTranslationMemories.php |
— | — | @@ -79,13 +79,14 @@ |
80 | 80 | */ |
81 | 81 | protected function doTMImport( LTTranslationMemory $tm, $memoryId ) { |
82 | 82 | $dbw = wfGetDB( DB_MASTER ); |
83 | | - |
| 83 | + |
84 | 84 | // Delete the memory from the db if already there. |
85 | 85 | $dbw->delete( |
86 | 86 | 'live_translate', |
87 | 87 | array( 'memory_id' => $memoryId ) |
88 | 88 | ); |
89 | 89 | |
| 90 | + // FIXME: this obviously goes wrong with multiple tms! |
90 | 91 | $wordId = 0; |
91 | 92 | |
92 | 93 | // Insert the memory in the db. |
— | — | @@ -98,7 +99,7 @@ |
99 | 100 | 'live_translate', |
100 | 101 | array( |
101 | 102 | 'word_id' => $wordId, |
102 | | - 'word_language' => $language, |
| 103 | + 'word_language' => $this->cleanLanguage( $language ), |
103 | 104 | 'word_translation' => $translation, |
104 | 105 | 'word_primary' => $primary, |
105 | 106 | 'memory_id' => $memoryId |
— | — | @@ -112,6 +113,26 @@ |
113 | 114 | } |
114 | 115 | } |
115 | 116 | } |
| 117 | + |
| 118 | + /** |
| 119 | + * Cleans the language code. |
| 120 | + * |
| 121 | + * @since 0.4 |
| 122 | + * |
| 123 | + * @param string language |
| 124 | + * |
| 125 | + * @return string |
| 126 | + */ |
| 127 | + protected function cleanLanguage( $language ) { |
| 128 | + $language = strtolower( $language ); |
| 129 | + $mappings = LiveTranslateFunctions::getInputLangMapping(); |
| 130 | + |
| 131 | + if ( array_key_exists( $language, $mappings ) ) { |
| 132 | + $language = $mappings[$language]; |
| 133 | + } |
| 134 | + |
| 135 | + return $language; |
| 136 | + } |
116 | 137 | |
117 | 138 | public function getAllowedParams() { |
118 | 139 | return array( |