Index: tags/extensions/LiveTranslate/REL_0_4/sql/LT_IndexWordTranslation.sql |
— | — | @@ -0,0 +1 @@ |
| 2 | +CREATE INDEX word_translation ON /*$wgDBprefix*/live_translate (word_id, word_language); |
Property changes on: tags/extensions/LiveTranslate/REL_0_4/sql/LT_IndexWordTranslation.sql |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 3 | + native |
Index: tags/extensions/LiveTranslate/REL_0_4/sql/LT_addTMField.sql |
— | — | @@ -0,0 +1,2 @@ |
| 2 | +ALTER TABLE /*_*/live_translate ADD COLUMN memory_id INT(4) unsigned NOT NULL; |
| 3 | +UPDATE /*_*/live_translate SET memory_id = 1; |
\ No newline at end of file |
Property changes on: tags/extensions/LiveTranslate/REL_0_4/sql/LT_addTMField.sql |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 4 | + native |
Index: tags/extensions/LiveTranslate/REL_0_4/LiveTranslate.i18n.php |
— | — | @@ -0,0 +1,530 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * Internationalization file for the Live Translate extension. |
| 6 | + * |
| 7 | + * @file LiveTranslate.i18n.php |
| 8 | + * @ingroup LiveTranslate |
| 9 | + * |
| 10 | + * @author Jeroen De Dauw < jeroendedauw@gmail.com > |
| 11 | + */ |
| 12 | + |
| 13 | +$messages = array(); |
| 14 | + |
| 15 | +/** English |
| 16 | + * @author Jeroen De Dauw |
| 17 | + */ |
| 18 | +$messages['en'] = array( |
| 19 | + 'livetranslate-desc' => 'Enables live translation of page content using the Google Translate service', |
| 20 | + |
| 21 | + // Translation interface |
| 22 | + 'livetranslate-translate-to' => 'Translate this page to', |
| 23 | + 'livetranslate-button-translate' => 'Translate', |
| 24 | + 'livetranslate-button-translating' => 'Translating...', |
| 25 | + 'livetranslate-button-revert' => 'Show original', |
| 26 | + 'livetranslate-dictionary-error' => 'Could not obtain the live translate dictionary. No words will be treated as special during the translation process.', |
| 27 | + |
| 28 | + // Special words dictionary |
| 29 | + 'livetranslate-dictionary-empty' => 'There are no words in the dictionary yet. Click the "edit" tab to add some.', |
| 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 | + '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.', |
| 33 | + |
| 34 | + // Special:LiveTranslate |
| 35 | + 'special-livetranslate' => 'Live translate', |
| 36 | + 'livetranslate-tmtype-ltf' => 'Live Translate format', |
| 37 | + 'livetranslate-tmtype-tmx' => 'Translation Memory eXchange', |
| 38 | + 'livetranslate-tmtype-gcsv' => 'Google CSV', |
| 39 | + 'livetranslate-special-no-tms-yet' => 'There are no translation memories yet.', |
| 40 | + 'livetranslate-special-button' => 'Save and update', |
| 41 | + 'livetranslate-special-type' => 'Type', |
| 42 | + 'livetranslate-special-location' => 'Location', |
| 43 | + 'livetranslate-special-remove' => 'Remove', |
| 44 | + 'livetranslate-special-local' => 'Local', |
| 45 | + 'livetranslate-special-add-tm' => 'Add a new translation memory', |
| 46 | + 'livetranslate-special-current-tms' => 'Existing translation memories', |
| 47 | + 'livetranslate-special-tms-update' => 'Update translation memories', |
| 48 | + 'livetranslate-special-update' => 'Update translation memories', |
| 49 | + |
| 50 | + // API ImportTranslationMemories |
| 51 | + 'livetranslate-importtms-param-miscmatch' => 'Mismatch between amount of locations and types', |
| 52 | +); |
| 53 | + |
| 54 | +/** Message documentation (Message documentation) |
| 55 | + * @author EugeneZelenko |
| 56 | + * @author Jeroen De Dauw |
| 57 | + * @author Raymond |
| 58 | + */ |
| 59 | +$messages['qqq'] = array( |
| 60 | + 'livetranslate-special-type' => 'Table column header on Special:LiveTranslate |
| 61 | + |
| 62 | +{{Identical|Type}}', |
| 63 | + 'livetranslate-special-location' => '{{Identical|Location}} |
| 64 | + |
| 65 | +Table column header on Special:LiveTranslate', |
| 66 | + 'livetranslate-special-remove' => '{{Identical|Remove}}', |
| 67 | + 'livetranslate-special-local' => 'Table column header on Special:LiveTranslate', |
| 68 | + 'livetranslate-importtms-param-miscmatch' => 'Error message for when one of the API modules gets called with a different amount of translation memory types compared to the amount of translation memory names', |
| 69 | +); |
| 70 | + |
| 71 | +/** Belarusian (Taraškievica orthography) (Беларуская (тарашкевіца)) |
| 72 | + * @author EugeneZelenko |
| 73 | + * @author Jim-by |
| 74 | + * @author Wizardist |
| 75 | + */ |
| 76 | +$messages['be-tarask'] = array( |
| 77 | + 'livetranslate-desc' => 'Дазваляе пераклады тэкстаў старонак на ляту ў Google Translate', |
| 78 | + 'livetranslate-translate-to' => 'Перакласьці гэту старонку на', |
| 79 | + 'livetranslate-button-translate' => 'Перакласьці', |
| 80 | + 'livetranslate-button-translating' => 'Ідзе пераклад…', |
| 81 | + 'livetranslate-button-revert' => 'Паказаць арыгінал', |
| 82 | + 'livetranslate-dictionary-error' => 'Немагчыма атрымаць слоўнік перакладу на ляту. Няма словаў, якая будуць разглядацца як спэцыяльныя, падчас працэсу перакладу.', |
| 83 | + 'livetranslate-dictionary-empty' => 'Пакуль што няма словаў у слоўніку. Націсьніце кнопку «рэдагаваць» каб дадаць.', |
| 84 | + 'livetranslate-dictionary-count' => 'Ёсьць $1 {{PLURAL:$1|слова|словы|словаў}} у $2 {{PLURAL:$2|мове|мовах|мовах}}. Націсьніце кнопку «рэдагаваць» каб дадаць болей.', |
| 85 | + 'livetranslate-dictionary-unallowed-langs' => '{{PLURAL:$2|Гэтая мова не дазволеная|Гэтыя мовы не дазволеныя}} у цяперашні момант як мэтавыя для перакладу: $1. Зьмяніце дазволеныя мовы ў Вашых наладах {{GRAMMAR:родны|{{SITENAME}}}}, ці выдаліце са слоўніка.', |
| 86 | + 'special-livetranslate' => 'Пераклад на ляту', |
| 87 | + 'livetranslate-tmtype-ltf' => 'Фармат перакладу на ляту', |
| 88 | + 'livetranslate-tmtype-tmx' => 'Абмен памяцьцю перакладаў', |
| 89 | + 'livetranslate-tmtype-gcsv' => 'Google CSV', |
| 90 | + 'livetranslate-special-no-tms-yet' => 'Пакуль што няма памяці перакладаў.', |
| 91 | + 'livetranslate-special-button' => 'Захаваць і абнавіць', |
| 92 | + 'livetranslate-special-type' => 'Тып', |
| 93 | + 'livetranslate-special-location' => 'Месцазнаходжаньне', |
| 94 | + 'livetranslate-special-remove' => 'Выдаліць', |
| 95 | + 'livetranslate-special-local' => 'Лякальная', |
| 96 | + 'livetranslate-special-add-tm' => 'Дадаць новую памяць перакладаў', |
| 97 | + 'livetranslate-special-current-tms' => 'Існуючыя памяці перакладаў', |
| 98 | + 'livetranslate-special-tms-update' => 'Абнавіць памяці перакладаў', |
| 99 | + 'livetranslate-special-update' => 'Абнавіць памяці перакладаў', |
| 100 | + 'livetranslate-importtms-param-miscmatch' => 'Несупадзеньне паміж колькасьцю знаходжаньняў і тыпамі', |
| 101 | +); |
| 102 | + |
| 103 | +/** Bulgarian (Български) |
| 104 | + * @author DCLXVI |
| 105 | + */ |
| 106 | +$messages['bg'] = array( |
| 107 | + 'livetranslate-button-translate' => 'Превеждане', |
| 108 | + 'livetranslate-button-translating' => 'Превеждане...', |
| 109 | +); |
| 110 | + |
| 111 | +/** Breton (Brezhoneg) |
| 112 | + * @author Fulup |
| 113 | + */ |
| 114 | +$messages['br'] = array( |
| 115 | + 'livetranslate-desc' => 'Aotren a ra treiñ danvez ur bajenn war-eeun en ur ober gant servij treiñ Google', |
| 116 | + 'livetranslate-translate-to' => 'Treiñ ar bajenn-mañ e', |
| 117 | + 'livetranslate-button-translate' => 'Treiñ', |
| 118 | + 'livetranslate-button-translating' => 'O treiñ...', |
| 119 | + 'livetranslate-button-revert' => 'Diskouez ar stumm orin', |
| 120 | + 'livetranslate-dictionary-error' => 'Dibosupl kavout troidigezh ar geriadur war ar prim. Ne vo pledet gant ger ebet en un doare dibar e-keit ha ne vo ket bet sevenet an droidigezh.', |
| 121 | + 'livetranslate-dictionary-empty' => 'Ger ebet er geriadur evit c\'hoazh. Klikit war an ivinell "kemmañ" evit ouzhpennañ unan.', |
| 122 | + 'livetranslate-dictionary-count' => '{{PLURAL:$1|$1 ger|$1 ger}} e $2 {{PLURAL:$2|yezh|yezh}} zo. Klikañ war an ivinell "kemmañ" da zegas re all.', |
| 123 | + 'livetranslate-dictionary-unallowed-langs' => "N'eo ket bet dibabet ar {{PLURAL:$2|yezh-mañ|ar yezhoù-mañ}} da yezh(où) da dreiñ daveto evit c'hoazh : $1. Cheñchit ar yezhoù aotreet dre ho kefluniadur wiki pe lamit anezho kuit eus ar geriadur.", |
| 124 | +); |
| 125 | + |
| 126 | +/** Bosnian (Bosanski) |
| 127 | + * @author CERminator |
| 128 | + */ |
| 129 | +$messages['bs'] = array( |
| 130 | + 'livetranslate-desc' => 'Omogućuje prevođenje uživo sadržaja stranice koristeći uslugu Google Translate', |
| 131 | + 'livetranslate-translate-to' => 'Prevedi ovu stranicu na', |
| 132 | + 'livetranslate-button-translate' => 'Prevedi', |
| 133 | + 'livetranslate-button-translating' => 'Prevodim...', |
| 134 | + 'livetranslate-button-revert' => 'Prikaži original', |
| 135 | + 'livetranslate-dictionary-error' => 'Ne može se pronaći rječnik za prevođenje uživo. Nijedna riječ neće biti posmatrana posebno tokom procesa prevođenja.', |
| 136 | + 'livetranslate-dictionary-empty' => "Još uvijek nema riječi u rječniku. Kliknite na jezičak ''uredi'' da ih dodate.", |
| 137 | + 'livetranslate-dictionary-count' => 'Ima {{PLURAL:$1|$1 riječ|$1 riječi}} na $2 {{PLURAL:$2|jeziku|jezika}}. Kliknite na jezičak "uredi" da dodate više.', |
| 138 | + 'livetranslate-dictionary-unallowed-langs' => '{{PLURAL:$2|Ovaj jezik nije|Ovi jezici nisu}} trenutno {{PLURAL:$2|postavljen|postavljeni}} kao dopušteni cilj prevođenja: $1. Promijenite dopuštene jezike u vašim postavkama wikija ili uklonite ove iz rječnika.', |
| 139 | +); |
| 140 | + |
| 141 | +/** German (Deutsch) |
| 142 | + * @author Kghbln |
| 143 | + */ |
| 144 | +$messages['de'] = array( |
| 145 | + 'livetranslate-desc' => 'Ermöglicht die unmittelbare Übersetzung des Seiteninhalts mit „Google Übersetzer“', |
| 146 | + 'livetranslate-translate-to' => 'Diese Seite in folgende Sprache übersetzen:', |
| 147 | + 'livetranslate-button-translate' => 'Übersetze', |
| 148 | + 'livetranslate-button-translating' => 'Übersetze …', |
| 149 | + 'livetranslate-button-revert' => 'Originalinhalt anzeigen', |
| 150 | + 'livetranslate-dictionary-error' => 'Das Wörterbuch konnte nicht geladen werden. Daher werden die in ihm enthaltenen Wörter nicht während des Übersetzungsvorgangs berücksichtigt.', |
| 151 | + 'livetranslate-dictionary-empty' => 'Momentan befinden sich keine Vokabeln im Wörterbuch. Auf „Bearbeiten“ klicken, um welche hinzuzufügen.', |
| 152 | + 'livetranslate-dictionary-count' => 'Momentan {{PLURAL:$1|befindet sich $1 Wort|befinden sich $1 Wörter}} in $2 {{PLURAL:$2|Sprache|Sprachen}} im Wörterbuch. Auf „Bearbeiten“ klicken, um weitere hinzuzufügen.', |
| 153 | + 'livetranslate-dictionary-unallowed-langs' => '{{PLURAL:$2|Diese Sprache ist|Diese Sprachen sind}} momentan nicht zum Übersetzen zugelassen: $1. Entweder nun die Einstellung der übersetzbaren Sprachen in der Wikikonfiguration anpassen oder diese aus dem Wörterbuch entfernen.', |
| 154 | + 'special-livetranslate' => 'Direktübersetzung', |
| 155 | + 'livetranslate-tmtype-ltf' => 'Live Translate format', |
| 156 | + 'livetranslate-tmtype-tmx' => 'Translation Memory eXchange', |
| 157 | + 'livetranslate-tmtype-gcsv' => 'Google-CSV', |
| 158 | + 'livetranslate-special-no-tms-yet' => 'Momentan sind keine Übersetzungsspeicher vorhanden.', |
| 159 | + 'livetranslate-special-button' => 'Speichern und aktualisieren', |
| 160 | + 'livetranslate-special-type' => 'Eingeben', |
| 161 | + 'livetranslate-special-location' => 'Ort', |
| 162 | + 'livetranslate-special-remove' => 'Entfernen', |
| 163 | + 'livetranslate-special-local' => 'Lokal', |
| 164 | + 'livetranslate-special-add-tm' => 'Einen neuen Übersetzungsspeicher anlegen', |
| 165 | + 'livetranslate-special-current-tms' => 'Vorhandene Übersetzungsspeicher', |
| 166 | + 'livetranslate-special-tms-update' => 'Übersetzungsspeicher aktualisieren', |
| 167 | + 'livetranslate-special-update' => 'Übersetzungsspeicher aktualisieren', |
| 168 | + 'livetranslate-importtms-param-miscmatch' => 'Missverhältnis zwischen Anzahl an Übersetzungsspeichern und Übersetzungsspeicherarten', |
| 169 | +); |
| 170 | + |
| 171 | +/** Lower Sorbian (Dolnoserbski) |
| 172 | + * @author Michawiki |
| 173 | + */ |
| 174 | +$messages['dsb'] = array( |
| 175 | + 'livetranslate-desc' => 'Zmóžnja direktne pśełožowanje wopśimjeśa boka z pomocu słužby "Google Translate"', |
| 176 | + 'livetranslate-translate-to' => 'Pśełož toś ten boko do', |
| 177 | + 'livetranslate-button-translate' => 'Pśełožyś', |
| 178 | + 'livetranslate-button-translating' => 'Pśełožujo se...', |
| 179 | + 'livetranslate-button-revert' => 'Original pokazaś', |
| 180 | + 'livetranslate-dictionary-error' => 'Słownik za Live Translate njedajo se zacytaś. Jogo słowa njezapśimuju se za pśełožowański proces.', |
| 181 | + 'livetranslate-dictionary-empty' => 'Hyšći njejsu žedne słowa w słowniku. Klikni na rejtark "wobźěłaś", aby někotare dodał.', |
| 182 | + 'livetranslate-dictionary-count' => '{{PLURAL:$1|Jo $1 słowo|Stej $1 słowje|Su $1 słowa|Jo $1 słowow}} w $2 {{PLURAL:$2|rěcy|rěcoma|rěcach|rěcach}}. Klikni na rejterk "wobźěłaś", aby dalšne dodał.', |
| 183 | + 'livetranslate-dictionary-unallowed-langs' => '{{PLURAL:$2|Toś ta rěc njejo|Toś tej rěcy njejstej|Toś te rěcy njejsu|Toś te rěcy njejsu}} tuchylu ako dowólony pśełožowański cel {{PLURAL:$2|nastajona|nastajonej|nastajone|nastajone}}: $1. Změń dowólone rěcy w konfiguraciji twójogo wikija abo wótpóraj te ze słownika.', |
| 184 | +); |
| 185 | + |
| 186 | +/** Basque (Euskara) |
| 187 | + * @author An13sa |
| 188 | + */ |
| 189 | +$messages['eu'] = array( |
| 190 | + 'livetranslate-button-translate' => 'Itzuli', |
| 191 | + 'livetranslate-button-translating' => 'Itzultzen...', |
| 192 | + 'livetranslate-button-revert' => 'Jatorrizkoa erakutsi', |
| 193 | +); |
| 194 | + |
| 195 | +/** French (Français) |
| 196 | + * @author Crochet.david |
| 197 | + * @author Sherbrooke |
| 198 | + */ |
| 199 | +$messages['fr'] = array( |
| 200 | + 'livetranslate-desc' => 'Permet la traduction immédiate du contenu de la page en utilisant le service de traduction de Google', |
| 201 | + 'livetranslate-translate-to' => 'Traduire cette page en', |
| 202 | + 'livetranslate-button-translate' => 'Traduire', |
| 203 | + 'livetranslate-button-translating' => 'Traduction en cours...', |
| 204 | + 'livetranslate-button-revert' => 'Afficher l’original', |
| 205 | + 'livetranslate-dictionary-error' => "Impossible d'obtenir la traduction immédiate du dictionnaire. Aucun mot ne recevra de traitement spécial pendant le processus de traduction.", |
| 206 | + 'livetranslate-dictionary-empty' => "Il n'y a aucun mot dans le dictionnaire encore. Cliquez sur l'onglet « Modifier » pour en ajouter.", |
| 207 | + 'livetranslate-dictionary-count' => "Il y a $1 {{PLURAL:$1|mot|mots}} dans {{PLURAL:$2|une langue|$2 langues}}. Cliquez sur l'onglet « Modifier » pour en ajouter.", |
| 208 | + 'livetranslate-dictionary-unallowed-langs' => "{{PLURAL:$2|Cette langue n'est pas sélectionnée comme langue cible|Ces langues ne sont pas sélectionnées comme langues cibles}} : $1. Modifiez les langues autorisées dans votre configuration de wiki ou supprimez-les du dictionnaire.", |
| 209 | + 'special-livetranslate' => 'Live translate', |
| 210 | + 'livetranslate-tmtype-ltf' => 'Format Live Translate', |
| 211 | + 'livetranslate-tmtype-tmx' => 'Translation Memory eXchange', |
| 212 | + 'livetranslate-tmtype-gcsv' => 'Google CSV', |
| 213 | + 'livetranslate-special-no-tms-yet' => "Il n'ya pas de mémoires de traduction pour le moment.", |
| 214 | + 'livetranslate-special-button' => 'Enregistrer et mettre à jour', |
| 215 | + 'livetranslate-special-type' => 'Type', |
| 216 | + 'livetranslate-special-location' => 'Localisation', |
| 217 | + 'livetranslate-special-remove' => 'Enlever', |
| 218 | + 'livetranslate-special-add-tm' => 'Ajouter une nouvelle mémoire de traduction', |
| 219 | + 'livetranslate-special-current-tms' => 'Mémoires de traduction existantes', |
| 220 | + 'livetranslate-special-tms-update' => 'Mise à jour de mémoires de traduction', |
| 221 | + 'livetranslate-special-update' => 'Mise à jour de mémoires de traduction', |
| 222 | + 'livetranslate-importtms-param-miscmatch' => "Incompatibilité entre la quantité d'emplacements et les types", |
| 223 | +); |
| 224 | + |
| 225 | +/** Galician (Galego) |
| 226 | + * @author Toliño |
| 227 | + */ |
| 228 | +$messages['gl'] = array( |
| 229 | + 'livetranslate-desc' => 'Activa a tradución en vivo do contido dunha páxina mediante o servizo de tradución do Google', |
| 230 | + 'livetranslate-translate-to' => 'Traducir esta páxina ao', |
| 231 | + 'livetranslate-button-translate' => 'Traducir', |
| 232 | + 'livetranslate-button-translating' => 'Traducindo...', |
| 233 | + 'livetranslate-button-revert' => 'Mostrar o orixinal', |
| 234 | +); |
| 235 | + |
| 236 | +/** Swiss German (Alemannisch) |
| 237 | + * @author Als-Holder |
| 238 | + */ |
| 239 | +$messages['gsw'] = array( |
| 240 | + 'livetranslate-desc' => 'Macht di diräkt Ibersetzig vum Syteninhalt megli mit „Google Ibersetzer“', |
| 241 | + 'livetranslate-translate-to' => 'Die Syte ibersetze in', |
| 242 | + 'livetranslate-button-translate' => 'Ibersetze', |
| 243 | + 'livetranslate-button-translating' => 'Am Ibersetze …', |
| 244 | + 'livetranslate-button-revert' => 'Originalinhalt aazeige', |
| 245 | + 'livetranslate-dictionary-error' => 'S Werterbuech het nit chenne glade wäre. Wäge däm wäre d Werter, wu s dert din het, bim Ibersetzigsvorgang nit berucksichtigt.', |
| 246 | + 'livetranslate-dictionary-empty' => 'Zurzyt het s kei Vokable im Werterbuech. Uf „Bearbeite“ klicke go ne baar yyfiege.', |
| 247 | + 'livetranslate-dictionary-count' => 'Zurzyt {{PLURAL:$1|git s $1 Wort|git s $1 Werter}} in $2 {{PLURAL:$2|Sproch|Sproche}} im Werterbuech. Uf „Bearbeite“ klicke go wyteri yyfiege.', |
| 248 | + 'livetranslate-dictionary-unallowed-langs' => '{{PLURAL:$2|Die Sproch isch|Die Sproche sin}} zurzyt nit zum Ibersetze zuegloo: $1. Entwäder jetz d Yystellig vu dr ibersetzbare Sproche in dr Wikikonfiguration aapasse oder die us em Werterbuech uuseneh.', |
| 249 | +); |
| 250 | + |
| 251 | +/** Upper Sorbian (Hornjoserbsce) |
| 252 | + * @author Michawiki |
| 253 | + */ |
| 254 | +$messages['hsb'] = array( |
| 255 | + 'livetranslate-desc' => 'Zmóžnja hnydomne přełožowanje wobsaha strony z pomocu słužby "Google Translate"', |
| 256 | + 'livetranslate-translate-to' => 'Přełož tutu stronu do', |
| 257 | + 'livetranslate-button-translate' => 'Přełožić', |
| 258 | + 'livetranslate-button-translating' => 'Přełožuje so...', |
| 259 | + 'livetranslate-button-revert' => 'Original pokazać', |
| 260 | + 'livetranslate-dictionary-error' => 'Słownik za Live Translate njeda so začitać. Jeho słowa so za přełožowanski proces njewobkedźbuja.', |
| 261 | + 'livetranslate-dictionary-empty' => 'Hišće žane słowa w słowniku njejsu. Klikń na rajtark "wobdźěłać", zo by někotre přidał.', |
| 262 | + 'livetranslate-dictionary-count' => '{{PLURAL:$1|Je $1 słowo|Stej $1 słowje|Su $1 słowa|Je $1 słowow}} w $2 {{PLURAL:$2|rěči|rěčomaj|rěčach|rěčach}}. Klikń na rajtark $wobdźěłać", zo by dalše přidał.', |
| 263 | + 'livetranslate-dictionary-unallowed-langs' => '{{PLURAL:$2|Tuta rěč njeje |Tutej rěči njejstej|Tute rěče njejsu|Tute rěče njejsu}} tuchwilu jako dowoleny přełožowanski cil {{PLURAL:$2|nastajena|nastajenej|nastajene|nastajene}}: $1. Změń dowolene rěče w konfiguraciji twojeho wikija abo wotstroń je ze słownika.', |
| 264 | + 'special-livetranslate' => 'Live translate', |
| 265 | + 'livetranslate-tmtype-ltf' => 'Live Translate format', |
| 266 | + 'livetranslate-tmtype-tmx' => 'Translation Memory eXchange', |
| 267 | + 'livetranslate-tmtype-gcsv' => 'Google-CSV', |
| 268 | + 'livetranslate-special-no-tms-yet' => 'Hišće přełožkowe składowaki njejsu.', |
| 269 | + 'livetranslate-special-button' => 'Składować a aktualizować', |
| 270 | + 'livetranslate-special-type' => 'Typ', |
| 271 | + 'livetranslate-special-location' => 'Městno', |
| 272 | + 'livetranslate-special-remove' => 'Wotstronić', |
| 273 | + 'livetranslate-special-local' => 'Lokalny', |
| 274 | + 'livetranslate-special-add-tm' => 'Nowy přełožkowy składowak přidać', |
| 275 | + 'livetranslate-special-current-tms' => 'Eksistowace přełožkowe składowaki', |
| 276 | + 'livetranslate-special-tms-update' => 'Přełožkowe składowaki aktualizować', |
| 277 | + 'livetranslate-special-update' => 'Přełožkowe składowaki aktualizować', |
| 278 | + 'livetranslate-importtms-param-miscmatch' => 'Njepoměr mjez ličbu městnow a typow', |
| 279 | +); |
| 280 | + |
| 281 | +/** Interlingua (Interlingua) |
| 282 | + * @author McDutchie |
| 283 | + */ |
| 284 | +$messages['ia'] = array( |
| 285 | + 'livetranslate-desc' => 'Permitte le traduction in directo de contento de paginas usante le servicio Google Translate', |
| 286 | + 'livetranslate-translate-to' => 'Traducer iste pagina in', |
| 287 | + 'livetranslate-button-translate' => 'Traducer', |
| 288 | + 'livetranslate-button-translating' => 'Traduction in curso...', |
| 289 | + 'livetranslate-button-revert' => 'Monstrar original', |
| 290 | + 'livetranslate-dictionary-error' => 'Non poteva obtener le dictionario de traduction in directo. Nulle parola essera tractate como special durante le processo de traduction.', |
| 291 | + 'livetranslate-dictionary-empty' => 'Le dictionario non ha ancora parolas. Clicca sur le scheda "modificar" pro adder alcunes.', |
| 292 | + 'livetranslate-dictionary-count' => 'Il ha {{PLURAL:$1|$1 parola|$1 parolas}} in $2 {{PLURAL:$2|linguas|linguas}}. Clicca sur le scheda "modificar" pro adder alteres.', |
| 293 | + 'livetranslate-dictionary-unallowed-langs' => 'Iste {{PLURAL:$2|lingua|linguas}} non es actualmente definite como destinationes valide pro traduction: $1. Modifica le linguas permittite in le configuration de tu wiki, o remove istes del dictionario.', |
| 294 | + 'special-livetranslate' => 'Traduction in directo', |
| 295 | + 'livetranslate-tmtype-ltf' => 'Formato de traduction in directo', |
| 296 | + 'livetranslate-tmtype-tmx' => 'Translation Memory eXchange', |
| 297 | + 'livetranslate-tmtype-gcsv' => 'CSV de Google', |
| 298 | + 'livetranslate-special-no-tms-yet' => 'Il non ha ancora memorias de traduction.', |
| 299 | + 'livetranslate-special-button' => 'Salveguardar e actualisar', |
| 300 | + 'livetranslate-special-type' => 'Typo', |
| 301 | + 'livetranslate-special-location' => 'Loco', |
| 302 | + 'livetranslate-special-remove' => 'Remover', |
| 303 | + 'livetranslate-special-local' => 'Local', |
| 304 | + 'livetranslate-special-add-tm' => 'Adder un nove memoria de traduction', |
| 305 | + 'livetranslate-special-current-tms' => 'Memorias de traduction existente', |
| 306 | + 'livetranslate-special-tms-update' => 'Actualisar memorias de traduction', |
| 307 | + 'livetranslate-special-update' => 'Actualisar memorias de traduction', |
| 308 | + 'livetranslate-importtms-param-miscmatch' => 'Le numero de locos differe del numero de typos', |
| 309 | +); |
| 310 | + |
| 311 | +/** Indonesian (Bahasa Indonesia) |
| 312 | + * @author IvanLanin |
| 313 | + */ |
| 314 | +$messages['id'] = array( |
| 315 | + 'livetranslate-desc' => 'Memungkinkan penerjemahan langsung konten halaman dengan menggunakan layanan Google Terjemahan', |
| 316 | + 'livetranslate-translate-to' => 'Terjemahkan halaman ini ke', |
| 317 | + 'livetranslate-button-translate' => 'Terjemahkan', |
| 318 | + 'livetranslate-button-translating' => 'Menerjemahkan ...', |
| 319 | + 'livetranslate-button-revert' => 'Tampilkan yang asli', |
| 320 | + 'livetranslate-dictionary-error' => 'Tidak dapat memperoleh kamus penerjemahan langsung. Tidak ada kata yang diperlakukan secara khusus selama proses penerjemahan.', |
| 321 | + 'livetranslate-dictionary-empty' => 'Belum tersedia kata dalam kamus. Klik tab "sunting" untuk menambahkan.', |
| 322 | + 'livetranslate-dictionary-count' => 'Ada {{PLURAL:$1|$1 kata|$1 kata}} dalam $2 {{PLURAL:$2|bahasa|bahasa}}. Klik tab "sunting" untuk menambakan.', |
| 323 | + 'livetranslate-dictionary-unallowed-langs' => '{{PLURAL:$2|Bahasa ini|Bahasa-bahasa ini}} disetel sebagai target terjemahan: $1. Ubah bahasa yang diizinkan dalam konfigurasi wiki, atau hapus dari kamus.', |
| 324 | +); |
| 325 | + |
| 326 | +/** Italian (Italiano) |
| 327 | + * @author Beta16 |
| 328 | + */ |
| 329 | +$messages['it'] = array( |
| 330 | + 'livetranslate-button-translate' => 'Traduci', |
| 331 | + 'livetranslate-button-translating' => 'Traduzione in corso...', |
| 332 | +); |
| 333 | + |
| 334 | +/** Japanese (日本語) |
| 335 | + * @author Ohgi |
| 336 | + */ |
| 337 | +$messages['ja'] = array( |
| 338 | + 'livetranslate-translate-to' => 'このページを翻訳', |
| 339 | + 'livetranslate-button-translate' => '翻訳', |
| 340 | + 'livetranslate-button-translating' => '翻訳中...', |
| 341 | +); |
| 342 | + |
| 343 | +/** Luxembourgish (Lëtzebuergesch) |
| 344 | + * @author Robby |
| 345 | + */ |
| 346 | +$messages['lb'] = array( |
| 347 | + 'livetranslate-desc' => 'Erméiglecht d\'live Iwwersetzen vu Säiteninhalt mam Service "Google Translate"', |
| 348 | + 'livetranslate-translate-to' => 'Iwwersetzt dës Säit op', |
| 349 | + 'livetranslate-button-translate' => 'Iwwersetzen', |
| 350 | + 'livetranslate-button-translating' => 'Iwwersetzen...', |
| 351 | + 'livetranslate-button-revert' => "D'Original weisen", |
| 352 | + 'livetranslate-dictionary-error' => 'De Live-Iwwersetzungs-Dictionnaire gouf net fonnt. Keng Wierder gi bei der Iwwersetzung als spezial ugekuckt.', |
| 353 | + 'livetranslate-dictionary-empty' => 'Et gëtt nach keng Wierder am Dictionnaire. Klickt op den "Änneren"-Tab fir der derbäizesetzen.', |
| 354 | + 'livetranslate-dictionary-count' => 'Et gëtt {{PLURAL:$1|ee Wuert|$1 Wierder}} a(n) {{PLURAL:$2|enger Sprooch|$2 Sproochen}}. Klickt den "Änneren"-Tab fir der derbäizesetzen.', |
| 355 | + 'livetranslate-dictionary-unallowed-langs' => "Dës {{PLURAL:$2|Sprooch ass|Sprooche si}} momentan net fir d'Iwwersetzen zougelooss: $1. Entweder ännert d'Astellung vun den erlaabte Sproochen an Ärer Wiki-Konfiguratioun oder huelt se aus dem Dictionnaire eraus.", |
| 356 | +); |
| 357 | + |
| 358 | +/** Macedonian (Македонски) |
| 359 | + * @author Bjankuloski06 |
| 360 | + */ |
| 361 | +$messages['mk'] = array( |
| 362 | + 'livetranslate-desc' => 'Овозможува преведување на содржината на една страница во живо, користејќи Google Translate', |
| 363 | + 'livetranslate-translate-to' => 'Преведи ја страницава на', |
| 364 | + 'livetranslate-button-translate' => 'Преведи', |
| 365 | + 'livetranslate-button-translating' => 'Преведувам...', |
| 366 | + 'livetranslate-button-revert' => 'Прикажи изворно', |
| 367 | + 'livetranslate-dictionary-error' => 'Не можев да го добијам речникот за преведување во живо. Ниеден збор нема да се смета за посебен во текот на преводната постапка.', |
| 368 | + 'livetranslate-dictionary-empty' => 'Сè уште нема зборови во речникот. Стиснете на јазичето „уреди“ и додајте некои.', |
| 369 | + 'livetranslate-dictionary-count' => 'Има {{PLURAL:$1|$1 збор|$1 збора}} на $2 {{PLURAL:$2|јазик|јазици}}. Ситиснете на јазичето „уреди“ за да додадете уште.', |
| 370 | + 'livetranslate-dictionary-unallowed-langs' => '{{PLURAL:$2|Овој јазик моментално не е зададен|Овие јазици моментално не се зададени}} како допуштена преводна одредница: $1. Изменете ги допуштените јазици во вики-поставките, или пак отстранете ги постоечкиве од речникот.', |
| 371 | + 'special-livetranslate' => 'Преведување во живо', |
| 372 | + 'livetranslate-tmtype-ltf' => 'Формат на преведувањето во живо', |
| 373 | + 'livetranslate-tmtype-tmx' => 'Translation Memory eXchange', |
| 374 | + 'livetranslate-tmtype-gcsv' => 'Google CSV', |
| 375 | + 'livetranslate-special-no-tms-yet' => 'Сè уште нема преводни памтила', |
| 376 | + 'livetranslate-special-button' => 'Зачувај и поднови', |
| 377 | + 'livetranslate-special-type' => 'Тип', |
| 378 | + 'livetranslate-special-location' => 'Место', |
| 379 | + 'livetranslate-special-remove' => 'Отстрани', |
| 380 | + 'livetranslate-special-local' => 'Локално', |
| 381 | + 'livetranslate-special-add-tm' => 'Додај ново преводно памтило', |
| 382 | + 'livetranslate-special-current-tms' => 'Постоечки преводни памтила', |
| 383 | + 'livetranslate-special-tms-update' => 'Поднови преводни памтила', |
| 384 | + 'livetranslate-special-update' => 'Поднови преводни памтила', |
| 385 | + 'livetranslate-importtms-param-miscmatch' => 'Бројот на местата и бројот на типовите не се совпаѓаат', |
| 386 | +); |
| 387 | + |
| 388 | +/** Dutch (Nederlands) |
| 389 | + * @author McDutchie |
| 390 | + * @author SPQRobin |
| 391 | + * @author Siebrand |
| 392 | + */ |
| 393 | +$messages['nl'] = array( |
| 394 | + 'livetranslate-desc' => 'Maakt het mogelijk paginainhoud live te vertalen met behulp van de dienst Google Translate', |
| 395 | + 'livetranslate-translate-to' => 'Pagina vertalen in het', |
| 396 | + 'livetranslate-button-translate' => 'Vertalen', |
| 397 | + 'livetranslate-button-translating' => 'Bezig met vertalen...', |
| 398 | + 'livetranslate-button-revert' => 'Origineel weergeven', |
| 399 | + 'livetranslate-dictionary-error' => 'Het was niet mogelijk het woordenboek voor livevertaling op te halen. Er zijn geen woorden die een speciale behandeling krijgen tijdens het vertaalproces.', |
| 400 | + 'livetranslate-dictionary-empty' => 'Er zijn nog geen woorden in het woordenboek. Klik op de tab "bewerken" om woorden toe te voegen.', |
| 401 | + 'livetranslate-dictionary-count' => 'Er {{PLURAL:$1|is één woord|zijn $1 woorden}} in $2 {{PLURAL:$2|taal|talen}}. Klik op de tab "bewerken" om meer woorden toe te voegen.', |
| 402 | + 'livetranslate-dictionary-unallowed-langs' => '{{PLURAL:$2|Deze taal is|Deze taken zijn}} niet ingesteld als toegestane doeltaal: $1. Wijzig te toegestane talen in de instellingen van uw wiki of verwijder ze uit het woordenboek.', |
| 403 | + 'special-livetranslate' => 'Live vertalen', |
| 404 | + 'livetranslate-tmtype-ltf' => 'Live Vertalen-opmaak', |
| 405 | + 'livetranslate-tmtype-tmx' => 'Translation Memory eXchange', |
| 406 | + 'livetranslate-tmtype-gcsv' => 'Google CSV', |
| 407 | + 'livetranslate-special-no-tms-yet' => 'Er zijn nog geen vertaalgeheugens.', |
| 408 | + 'livetranslate-special-button' => 'Opslaan en bijwerken', |
| 409 | + 'livetranslate-special-type' => 'Type', |
| 410 | + 'livetranslate-special-location' => 'Locatie', |
| 411 | + 'livetranslate-special-remove' => 'Verwijderen', |
| 412 | + 'livetranslate-special-local' => 'Lokaal', |
| 413 | + 'livetranslate-special-add-tm' => 'Nieuw vertaalgeheugen toevoegen', |
| 414 | + 'livetranslate-special-current-tms' => 'Bestaande vertaalgeheugens', |
| 415 | + 'livetranslate-special-tms-update' => 'Vertaalgeheugens bijwerken', |
| 416 | + 'livetranslate-special-update' => 'Vertaalgeheugens bijwerken', |
| 417 | + 'livetranslate-importtms-param-miscmatch' => 'Er is een verschil tussen het aantal locaties en typen', |
| 418 | +); |
| 419 | + |
| 420 | +/** Norwegian (bokmål) (Norsk (bokmål)) |
| 421 | + * @author Nghtwlkr |
| 422 | + */ |
| 423 | +$messages['no'] = array( |
| 424 | + 'livetranslate-desc' => 'Aktiverer live-oversettelse av sideinnhold ved hjelp av tjenesten Google Translate', |
| 425 | + 'livetranslate-translate-to' => 'Oversett denne siden til', |
| 426 | + 'livetranslate-button-translate' => 'Oversett', |
| 427 | + 'livetranslate-button-translating' => 'Oversetter...', |
| 428 | + 'livetranslate-button-revert' => 'Vis opprinnelig', |
| 429 | + 'livetranslate-dictionary-error' => 'Kunne ikke få tak i sanntidsoversettelsesordlisten. Ingen ord vil bli behandlet som spesielle under oversettelsesprosessen.', |
| 430 | + 'livetranslate-dictionary-empty' => 'Det er ingen ord i ordlisten ennå. Klikk på «rediger»-fanen for å legge til noen.', |
| 431 | + 'livetranslate-dictionary-count' => 'Det er {{PLURAL:$1|ett ord|$1 ord}} i $2 {{PLURAL:$2|språk|språk}}. Klikk på «rediger»-fanen for å legge til flere.', |
| 432 | + 'livetranslate-dictionary-unallowed-langs' => '{{PLURAL:$2|Dette språket|Disse språkene}} er for øyeblikket ikke satt som tillatte oversettelsesmål: $1. Endre tillatte språk i din wikis konfigurasjon eller fjern disse fra ordlisten.', |
| 433 | +); |
| 434 | + |
| 435 | +/** Polish (Polski) |
| 436 | + * @author Byulent |
| 437 | + * @author Sp5uhe |
| 438 | + */ |
| 439 | +$messages['pl'] = array( |
| 440 | + 'livetranslate-desc' => 'Włącza tłumaczenie zawartości strony na żywo z wykorzystaniem serwisu tłumaczącego Google', |
| 441 | + 'livetranslate-translate-to' => 'Przetłumacz tę stronę na', |
| 442 | + 'livetranslate-button-translate' => 'Tłumacz', |
| 443 | + 'livetranslate-button-translating' => 'Tłumaczenie...', |
| 444 | + 'livetranslate-button-revert' => 'Pokaż w oryginale', |
| 445 | + 'livetranslate-dictionary-error' => 'Nie można uzyskać dostępu na żywo do słownika tłumaczącego. Żadne słowo nie będzie traktowane specjalnie w czasie wykonywania tłumaczenia.', |
| 446 | + 'livetranslate-dictionary-empty' => 'Na razie brak jest jeszcze słów w słowniku. Kliknij zakładkę „Edytuj“ aby jakieś dodać.', |
| 447 | + 'livetranslate-dictionary-count' => '{{PLURAL:$1|Jest $1 słowo|Są $1 słowa|Jest $1 słów}} w $2 {{PLURAL:$2|języku|językach}}. Kliknij zakładkę „Edytuj“ aby dodać następne.', |
| 448 | + 'livetranslate-dictionary-unallowed-langs' => '{{PLURAL:$2|Język $1 nie jest obecnie dostępny jako docelowy|Języki $1 nie są obecnie dostępne jako docelowe}} dla tłumaczeń. Zmień dopuszczalne języki w konfiguracji swojej wiki lub usuń to ze słownika.', |
| 449 | +); |
| 450 | + |
| 451 | +/** Piedmontese (Piemontèis) |
| 452 | + * @author Dragonòt |
| 453 | + */ |
| 454 | +$messages['pms'] = array( |
| 455 | + 'livetranslate-desc' => 'A abìlita viragi dal viv ëd contnù ëd pàgine an dovrand ël sërvissi Google Translate', |
| 456 | + 'livetranslate-translate-to' => 'Vòlta sta pàgina an', |
| 457 | + 'livetranslate-button-translate' => 'Traduv', |
| 458 | + 'livetranslate-button-translating' => 'Volté...', |
| 459 | + 'livetranslate-button-revert' => 'Mosta original', |
| 460 | + 'livetranslate-dictionary-error' => 'As peul pa avèj ël dissionari ëd viragi viv. Pa gnun-e paròle a saran tratà com speciaj an mente dël process ëd viragi.', |
| 461 | + 'livetranslate-dictionary-empty' => 'A-i é pa anco\' gnun-e paròle ant ël dissionari. Sgnaca ël boton "modìfica" për giuntene quaidun-e.', |
| 462 | + 'livetranslate-dictionary-count' => 'A-i {{PLURAL:$1|é $1 paròla|son $1 paròle}} an $2 {{PLURAL:$2|lenga|lenghe}}. Sgnaca ël boton "modìfica" për giontene ëd pi.', |
| 463 | + 'livetranslate-dictionary-unallowed-langs' => "{{PLURAL:$2|Sta lenga a l'é|Ste lenghe a son}} al moment pa ampostà com obietiv përmëttù ed viragi: $1. Modìfica le lenghe përmëttùe ant la configurassion ëd toe wiki, o gav-je dal dissionari.", |
| 464 | +); |
| 465 | + |
| 466 | +/** Portuguese (Português) |
| 467 | + * @author Hamilton Abreu |
| 468 | + */ |
| 469 | +$messages['pt'] = array( |
| 470 | + 'livetranslate-desc' => 'Permite a tradução imediata do conteúdo das páginas usando o serviço Google Translate', |
| 471 | + 'livetranslate-translate-to' => 'Traduzir esta página para', |
| 472 | + 'livetranslate-button-translate' => 'Traduzir', |
| 473 | + 'livetranslate-button-translating' => 'A traduzir...', |
| 474 | + 'livetranslate-button-revert' => 'Mostrar original', |
| 475 | + 'livetranslate-dictionary-error' => 'Não foi possível obter o dicionário de tradução imediata. Durante o processo de tradução, nenhuma palavra será considerada especial.', |
| 476 | + 'livetranslate-dictionary-empty' => 'Ainda não existem palavras no dicionário. Clique o separador "editar" para adicionar algumas.', |
| 477 | + 'livetranslate-dictionary-count' => '{{PLURAL:$1|Existe $1 palavra|Existem $1 palavras}} de $2 {{PLURAL:$2|língua|línguas}}. Clique o separador "editar" para acrescentar mais.', |
| 478 | + 'livetranslate-dictionary-unallowed-langs' => '{{PLURAL:$2|Esta língua não está definida como destino válido|Estas línguas não estão definidas como destinos válidos}} para tradução: $1. Altere na configuração da wiki as línguas permitidas, ou remova estas do dicionário.', |
| 479 | +); |
| 480 | + |
| 481 | +/** Brazilian Portuguese (Português do Brasil) |
| 482 | + * @author Giro720 |
| 483 | + */ |
| 484 | +$messages['pt-br'] = array( |
| 485 | + 'livetranslate-desc' => 'Permite a tradução imediata do conteúdo das páginas usando o serviço Google Translate', |
| 486 | + 'livetranslate-translate-to' => 'Traduzir esta página para', |
| 487 | + 'livetranslate-button-translate' => 'Traduzir', |
| 488 | + 'livetranslate-button-translating' => 'Traduzindo...', |
| 489 | +); |
| 490 | + |
| 491 | +/** Russian (Русский) |
| 492 | + * @author Byulent |
| 493 | + * @author MaxSem |
| 494 | + * @author Александр Сигачёв |
| 495 | + */ |
| 496 | +$messages['ru'] = array( |
| 497 | + 'livetranslate-desc' => 'Включает перевод текста страницы на лету с помощью службы переводов Google', |
| 498 | + 'livetranslate-translate-to' => 'Перевести эту страницу на', |
| 499 | + 'livetranslate-button-translate' => 'Перевести', |
| 500 | + 'livetranslate-button-translating' => 'Выполняется перевод...', |
| 501 | + 'livetranslate-button-revert' => 'Показать оригинал', |
| 502 | + 'livetranslate-dictionary-error' => 'Не удалось получить словарь живого перевода. Нет слов, которые будут рассматриваться как специальные во время процесса перевода.', |
| 503 | + 'livetranslate-dictionary-empty' => 'В словаре ещё нет слов. Нажмите «править», чтобы добавить несколько.', |
| 504 | + 'livetranslate-dictionary-count' => '$1 {{PLURAL:$1|слово|слова|слов}} на $2 {{PLURAL:$2|языке|языках|языках}}. Нажмите «править», чтобы добавить ещё.', |
| 505 | + 'livetranslate-dictionary-unallowed-langs' => '{{PLURAL:$2|Этот язык|Эти языки}} не разрешено использовать в качестве цели перевода: $1. Измените разрешения в настройках вашей вики, или удалите их из словаря.', |
| 506 | +); |
| 507 | + |
| 508 | +/** Telugu (తెలుగు) |
| 509 | + * @author Veeven |
| 510 | + */ |
| 511 | +$messages['te'] = array( |
| 512 | + 'livetranslate-translate-to' => 'ఈ పుటని అనువదించండి', |
| 513 | + 'livetranslate-button-translate' => 'అనువదించు', |
| 514 | + 'livetranslate-button-translating' => 'అనువదిస్తున్నాం...', |
| 515 | +); |
| 516 | + |
| 517 | +/** Ukrainian (Українська) |
| 518 | + * @author Тест |
| 519 | + */ |
| 520 | +$messages['uk'] = array( |
| 521 | + 'livetranslate-desc' => 'Робить можливим безпосередній переклад вмісту сторінки за допомогою служби Google Translate', |
| 522 | + 'livetranslate-translate-to' => 'Перекласти цю сторінку', |
| 523 | + 'livetranslate-button-translate' => 'Перекласти', |
| 524 | + 'livetranslate-button-translating' => 'Перекладаю...', |
| 525 | + 'livetranslate-button-revert' => 'Показати оригінал', |
| 526 | + 'livetranslate-special-button' => 'Зберегти та оновити', |
| 527 | + 'livetranslate-special-type' => 'Тип', |
| 528 | + 'livetranslate-special-location' => 'Розташування', |
| 529 | + 'livetranslate-special-remove' => 'Вилучити', |
| 530 | +); |
| 531 | + |
Property changes on: tags/extensions/LiveTranslate/REL_0_4/LiveTranslate.i18n.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 532 | + native |
Index: tags/extensions/LiveTranslate/REL_0_4/LiveTranslate.php |
— | — | @@ -0,0 +1,106 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * Initialization file for the Live Translate extension. |
| 6 | + * |
| 7 | + * Documentation: http://www.mediawiki.org/wiki/Extension:Live_Translate |
| 8 | + * Support http://www.mediawiki.org/wiki/Extension_talk:Live_Translate |
| 9 | + * Source code: http://svn.wikimedia.org/viewvc/mediawiki/trunk/extensions/LiveTranslate |
| 10 | + * |
| 11 | + * @file LiveTranslate.php |
| 12 | + * @ingroup LiveTranslate |
| 13 | + * |
| 14 | + * @licence GNU GPL v3 |
| 15 | + * |
| 16 | + * @author Jeroen De Dauw < jeroendedauw@gmail.com > |
| 17 | + */ |
| 18 | + |
| 19 | +/** |
| 20 | + * This documenation group collects source code files belonging to Live Translate. |
| 21 | + * |
| 22 | + * @defgroup LiveTranslate Live Translate |
| 23 | + */ |
| 24 | + |
| 25 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 26 | + die( 'Not an entry point.' ); |
| 27 | +} |
| 28 | + |
| 29 | +define( 'LiveTranslate_VERSION', '0.4 alpha' ); |
| 30 | + |
| 31 | +$wgExtensionCredits['other'][] = array( |
| 32 | + 'path' => __FILE__, |
| 33 | + 'name' => 'Live Translate', |
| 34 | + 'version' => LiveTranslate_VERSION, |
| 35 | + 'author' => array( |
| 36 | + '[http://www.mediawiki.org/wiki/User:Jeroen_De_Dauw Jeroen De Dauw] for [http://www.wikiworks.com WikiWorks]', |
| 37 | + ), |
| 38 | + 'url' => 'http://www.mediawiki.org/wiki/Extension:Live_Translate', |
| 39 | + 'descriptionmsg' => 'livetranslate-desc' |
| 40 | +); |
| 41 | + |
| 42 | +$useExtensionPath = version_compare( $wgVersion, '1.16', '>=' ) && isset( $wgExtensionAssetsPath ) && $wgExtensionAssetsPath; |
| 43 | +$egLiveTranslateScriptPath = ( $useExtensionPath ? $wgExtensionAssetsPath : $wgScriptPath . '/extensions' ) . '/LiveTranslate'; |
| 44 | +$egLiveTranslateIP = dirname( __FILE__ ); |
| 45 | +unset( $useExtensionPath ); |
| 46 | + |
| 47 | +$wgExtensionMessagesFiles['LiveTranslate'] = $egLiveTranslateIP . '/LiveTranslate.i18n.php'; |
| 48 | + |
| 49 | +$wgAutoloadClasses['LiveTranslateHooks'] = $egLiveTranslateIP . '/LiveTranslate.hooks.php'; |
| 50 | +$wgAutoloadClasses['ApiImportTranslationMemories'] = $egLiveTranslateIP . '/api/ApiImportTranslationMemories.php'; |
| 51 | +$wgAutoloadClasses['ApiLiveTranslate'] = $egLiveTranslateIP . '/api/ApiLiveTranslate.php'; |
| 52 | +$wgAutoloadClasses['ApiQueryLiveTranslate'] = $egLiveTranslateIP . '/api/ApiQueryLiveTranslate.php'; |
| 53 | + |
| 54 | +$incDirIP = $egLiveTranslateIP . '/includes/'; |
| 55 | +$wgAutoloadClasses['LiveTranslateFunctions'] = $incDirIP . 'LiveTranslate_Functions.php'; |
| 56 | +$wgAutoloadClasses['LTGCSVParser'] = $incDirIP . 'LT_GCSVParser.php'; |
| 57 | +$wgAutoloadClasses['LTLTFParser'] = $incDirIP . 'LT_LTFParser.php'; |
| 58 | +$wgAutoloadClasses['LTTMParser'] = $incDirIP . 'LT_TMParser.php'; |
| 59 | +$wgAutoloadClasses['LTTMUnit'] = $incDirIP . 'LT_TMUnit.php'; |
| 60 | +$wgAutoloadClasses['LTTMXParser'] = $incDirIP . 'LT_TMXParser.php'; |
| 61 | +$wgAutoloadClasses['LTTranslationMemory'] = $incDirIP . 'LT_TranslationMemory.php'; |
| 62 | +unset( $incDirIP ); |
| 63 | + |
| 64 | +$wgAutoloadClasses['SpecialLiveTranslate'] = $egLiveTranslateIP . '/specials/SpecialLiveTranslate.php'; |
| 65 | + |
| 66 | +$wgSpecialPages['LiveTranslate'] = 'SpecialLiveTranslate'; |
| 67 | +$wgSpecialPageGroups['LiveTranslate'] = 'pagetools'; |
| 68 | + |
| 69 | +$wgAPIModules['importtms'] = 'ApiImportTranslationMemories'; |
| 70 | +$wgAPIModules['livetranslate'] = 'ApiLiveTranslate'; |
| 71 | +$wgAPIListModules['livetranslate'] = 'ApiQueryLiveTranslate'; |
| 72 | + |
| 73 | +$wgHooks['ArticleViewHeader'][] = 'LiveTranslateHooks::onArticleViewHeader'; |
| 74 | +$wgHooks['LoadExtensionSchemaUpdates'][] = 'LiveTranslateHooks::onSchemaUpdate'; |
| 75 | +$wgHooks['ArticleSaveComplete'][] = 'LiveTranslateHooks::onArticleSaveComplete'; |
| 76 | + |
| 77 | +$egLTJSMessages = array( |
| 78 | + 'livetranslate-button-translate', |
| 79 | + 'livetranslate-button-translating', |
| 80 | + 'livetranslate-dictionary-error', |
| 81 | +); |
| 82 | + |
| 83 | +// For backward compatibility with MW < 1.17. |
| 84 | +if ( is_callable( array( 'OutputPage', 'addModules' ) ) ) { |
| 85 | + $moduleTemplate = array( |
| 86 | + 'localBasePath' => dirname( __FILE__ ), |
| 87 | + 'remoteBasePath' => $egLiveTranslateScriptPath, |
| 88 | + 'group' => 'ext.livetranslate' |
| 89 | + ); |
| 90 | + |
| 91 | + $wgResourceModules['ext.livetranslate'] = $moduleTemplate + array( |
| 92 | + 'scripts' => array( 'includes/ext.livetranslate.js' ), |
| 93 | + 'dependencies' => array(), |
| 94 | + 'messages' => $egLTJSMessages |
| 95 | + ); |
| 96 | +} |
| 97 | + |
| 98 | +/** |
| 99 | + * Enum for translation memory types. |
| 100 | + * |
| 101 | + * @since 0.4 |
| 102 | + */ |
| 103 | +define( 'TMT_LTF', 0 ); |
| 104 | +define( 'TMT_TMX', 1 ); |
| 105 | +define( 'TMT_GCSV', 2 ); |
| 106 | + |
| 107 | +require_once 'LiveTranslate_Settings.php'; |
Property changes on: tags/extensions/LiveTranslate/REL_0_4/LiveTranslate.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 108 | + native |
Index: tags/extensions/LiveTranslate/REL_0_4/LiveTranslate_Settings.php |
— | — | @@ -0,0 +1,34 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * File defining the settings for the Live Translate extension. |
| 6 | + * More info can be found at http://www.mediawiki.org/wiki/Extension:LiveTranslate#Configuration |
| 7 | + * |
| 8 | + * NOTICE: |
| 9 | + * Changing one of these settings can be done by copieng or cutting it, |
| 10 | + * and placing it in LocalSettings.php, AFTER the inclusion of Live Translate. |
| 11 | + * |
| 12 | + * @file LiveTranslate_Settings.php |
| 13 | + * @ingroup LiveTranslate |
| 14 | + * |
| 15 | + * @author Jeroen De Dauw < jeroendedauw@gmail.com > |
| 16 | + */ |
| 17 | + |
| 18 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 19 | + die( 'Not an entry point.' ); |
| 20 | +} |
| 21 | + |
| 22 | +# https://code.google.com/apis/console |
| 23 | +$egGoogleApiKey = ''; |
| 24 | + |
| 25 | +# A list of languages that should be available to translate to. |
| 26 | +$egLiveTranslateLanguages = array( |
| 27 | + $wgLanguageCode, |
| 28 | +); |
| 29 | + |
| 30 | +# Permission to mannage translation memories. |
| 31 | +$wgGroupPermissions['sysop']['managetms'] = true; |
| 32 | + |
| 33 | +# Default translation memory type. |
| 34 | +# TMT_LTF, TMT_TMX, TMT_GCSV |
| 35 | +$egLiveTranslateTMT = TMT_LTF; |
Property changes on: tags/extensions/LiveTranslate/REL_0_4/LiveTranslate_Settings.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 36 | + native |
Index: tags/extensions/LiveTranslate/REL_0_4/specials/SpecialLiveTranslate.php |
— | — | @@ -0,0 +1,367 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * Page to manage LiveTranslate translation memories. |
| 6 | + * |
| 7 | + * @since 0.4 |
| 8 | + * |
| 9 | + * @file SpecialLiveTranslate.php |
| 10 | + * @ingroup LiveTranslate |
| 11 | + * |
| 12 | + * @licence GNU GPL v3 or later |
| 13 | + * @author Jeroen De Dauw < jeroendedauw@gmail.com > |
| 14 | + */ |
| 15 | +class SpecialLiveTranslate extends SpecialPage { |
| 16 | + |
| 17 | + /** |
| 18 | + * Constructor. |
| 19 | + * |
| 20 | + * @since 0.4 |
| 21 | + */ |
| 22 | + public function __construct() { |
| 23 | + parent::__construct( 'LiveTranslate', 'managetms' ); |
| 24 | + } |
| 25 | + |
| 26 | + /** |
| 27 | + * @see SpecialPage::getDescription |
| 28 | + * |
| 29 | + * @since 0.4 |
| 30 | + */ |
| 31 | + public function getDescription() { |
| 32 | + return wfMsg( 'special-' . strtolower( $this->mName ) ); |
| 33 | + } |
| 34 | + |
| 35 | + /** |
| 36 | + * Sets headers - this should be called from the execute() method of all derived classes! |
| 37 | + * |
| 38 | + * @since 0.4 |
| 39 | + */ |
| 40 | + public function setHeaders() { |
| 41 | + global $wgOut; |
| 42 | + $wgOut->setArticleRelated( false ); |
| 43 | + $wgOut->setRobotPolicy( "noindex,nofollow" ); |
| 44 | + $wgOut->setPageTitle( $this->getDescription() ); |
| 45 | + } |
| 46 | + |
| 47 | + /** |
| 48 | + * Main method. |
| 49 | + * |
| 50 | + * @since 0.4 |
| 51 | + * |
| 52 | + * @param string $arg |
| 53 | + */ |
| 54 | + public function execute( $arg ) { |
| 55 | + global $wgOut, $wgUser, $wgRequest; |
| 56 | + |
| 57 | + $this->setHeaders(); |
| 58 | + $this->outputHeader(); |
| 59 | + |
| 60 | + // If the user is authorized, display the page, if not, show an error. |
| 61 | + if ( !$this->userCanExecute( $wgUser ) ) { |
| 62 | + $this->displayRestrictionError(); |
| 63 | + return; |
| 64 | + } |
| 65 | + |
| 66 | + if ( $wgRequest->wasPosted() && $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) { |
| 67 | + $this->handleSubmission(); |
| 68 | + } |
| 69 | + |
| 70 | + $tms = $this->getTMConfigItems(); |
| 71 | + |
| 72 | + $this->displayTMConfig( $tms ); |
| 73 | + |
| 74 | + $this->updateTranslationMemory( $tms ); |
| 75 | + } |
| 76 | + |
| 77 | + /** |
| 78 | + * Handles the submission of the config form. |
| 79 | + * |
| 80 | + * @since 0.4 |
| 81 | + */ |
| 82 | + protected function handleSubmission() { |
| 83 | + global $wgRequest; |
| 84 | + |
| 85 | + $tms = $this->getTMConfigItems(); |
| 86 | + |
| 87 | + $dbw = wfGetDB( DB_MASTER ); |
| 88 | + |
| 89 | + // Loop over the existing translation memories and update/delete them if requested. |
| 90 | + foreach ( $tms as $tm ) { |
| 91 | + // If a delete has been requested, remove the item. |
| 92 | + if ( $wgRequest->getCheck( 'tmdel-' . $tm->memory_id ) ) { |
| 93 | + $dbw->delete( |
| 94 | + 'live_translate_memories', |
| 95 | + array( 'memory_id' => $tm->memory_id ) |
| 96 | + ); |
| 97 | + } |
| 98 | + // If changes where made, apply them in the db. |
| 99 | + elseif ( |
| 100 | + $wgRequest->getText( 'tmlocation-' . $tm->memory_id ) != $tm->memory_location |
| 101 | + || $wgRequest->getInt( 'wptmtype-' . $tm->memory_id ) != $tm->memory_type |
| 102 | + || ( $wgRequest->getCheck( 'tmlocal-' . $tm->memory_id ) ? 1 : 0 ) != $tm->memory_local |
| 103 | + ) { |
| 104 | + $dbw->update( |
| 105 | + 'live_translate_memories', |
| 106 | + array( |
| 107 | + 'memory_location' => $wgRequest->getText( 'tmlocation-' . $tm->memory_id ), |
| 108 | + 'memory_type' => $wgRequest->getInt( 'wptmtype-' . $tm->memory_id ), |
| 109 | + 'memory_local' => $wgRequest->getCheck( 'tmlocal-' . $tm->memory_id ) ? 1 : 0 |
| 110 | + ), |
| 111 | + array( 'memory_id' => $tm->memory_id ) |
| 112 | + ); |
| 113 | + } |
| 114 | + } |
| 115 | + |
| 116 | + // If there is a new item, insert it. |
| 117 | + if ( $wgRequest->getText( 'newtm-location' ) != '' ) { |
| 118 | + $dbw->insert( |
| 119 | + 'live_translate_memories', |
| 120 | + array( |
| 121 | + 'memory_type' => $wgRequest->getInt( 'wpnewtm-type' ), |
| 122 | + 'memory_location' => $wgRequest->getText( 'newtm-location' ), |
| 123 | + 'memory_local' => $wgRequest->getCheck( 'newtm-local' ) ? 1 : 0 |
| 124 | + ) |
| 125 | + ); |
| 126 | + } |
| 127 | + } |
| 128 | + |
| 129 | + /** |
| 130 | + * Updates the translation memory stored in the db. |
| 131 | + * |
| 132 | + * @since 0.4 |
| 133 | + * |
| 134 | + * @param array $tms The current translation memories |
| 135 | + */ |
| 136 | + protected function updateTranslationMemory( array $tms ) { |
| 137 | + $dbr = wfGetDB( DB_SLAVE ); |
| 138 | + |
| 139 | + // Just drop everything and rebuild the entire translation memory. |
| 140 | + $dbr->query( 'TRUNCATE TABLE ' . $dbr->tableName( 'live_translate' ) ); |
| 141 | + |
| 142 | + foreach ( $tms as $tm ) { |
| 143 | + $requestData = array( |
| 144 | + 'action' => 'importtms', |
| 145 | + 'format' => 'json', |
| 146 | + 'source' => $tm->memory_location, |
| 147 | + 'type' => $tm->memory_type, |
| 148 | + 'local' => $tm->memory_local, |
| 149 | + ); |
| 150 | + |
| 151 | + $api = new ApiMain( new FauxRequest( $requestData, true ), true ); |
| 152 | + $api->execute(); |
| 153 | + $response = $api->getResultData(); |
| 154 | + } |
| 155 | + } |
| 156 | + |
| 157 | + /** |
| 158 | + * Displays the translation memories config table. |
| 159 | + * |
| 160 | + * @since 0.4 |
| 161 | + * |
| 162 | + * @param array $tms The current translation memories |
| 163 | + */ |
| 164 | + protected function displayTMConfig( array $tms ) { |
| 165 | + global $wgOut, $wgUser; |
| 166 | + |
| 167 | + $wgOut->addHtml( Html::openElement( |
| 168 | + 'form', |
| 169 | + array( |
| 170 | + 'id' => 'tmform', |
| 171 | + 'name' => 'tmform', |
| 172 | + 'method' => 'post', |
| 173 | + 'action' => $this->getTitle()->getLocalURL(), |
| 174 | + ) |
| 175 | + ) ); |
| 176 | + |
| 177 | + if ( count( $tms ) > 0 ) { |
| 178 | + /* |
| 179 | + $wgOut->addHTML( '<h3>' . htmlspecialchars( wfMsg( 'livetranslate-special-tms-update' ) ) . '</h3>' ); |
| 180 | + |
| 181 | + $wgOut->addHTML( |
| 182 | + Html::input( |
| 183 | + '', |
| 184 | + wfMsg( 'livetranslate-special-update' ), |
| 185 | + 'submit', |
| 186 | + array( 'id' => 'tmform-updatesubmit' ) |
| 187 | + ) |
| 188 | + ); |
| 189 | + */ |
| 190 | + |
| 191 | + $wgOut->addHTML( '<h3>' . htmlspecialchars( wfMsg( 'livetranslate-special-current-tms' ) ) . '</h3>' ); |
| 192 | + |
| 193 | + $wgOut->addHTML( Html::openElement( |
| 194 | + 'table', |
| 195 | + array( 'class' => 'wikitable', 'style' => 'width:50%' ) |
| 196 | + ) ); |
| 197 | + |
| 198 | + $wgOut->addHTML( Html::rawElement( |
| 199 | + 'tr', |
| 200 | + array(), |
| 201 | + Html::element( 'th', array( 'width' => '400px' ), wfMsg( 'livetranslate-special-location' ) ) . |
| 202 | + Html::element( 'th', array( 'width' => '160px' ), wfMsg( 'livetranslate-special-type' ) ) . |
| 203 | + Html::element( 'th', array( 'width' => '160px' ), wfMsg( 'livetranslate-special-local' ) ) . |
| 204 | + Html::element( 'th', array( 'width' => '100px' ), wfMsg( 'livetranslate-special-remove' ) ) |
| 205 | + ) ); |
| 206 | + |
| 207 | + foreach ( $tms as $tm ) { |
| 208 | + $this->displayTMItem( $tm ); |
| 209 | + } |
| 210 | + |
| 211 | + $wgOut->addHTML( Html::closeElement( 'table' ) ); |
| 212 | + } |
| 213 | + else { |
| 214 | + $wgOut->addWikiMsg( 'livetranslate-special-no-tms-yet' ); |
| 215 | + } |
| 216 | + |
| 217 | + $this->displayAddNewTM(); |
| 218 | + |
| 219 | + $wgOut->addHtml( |
| 220 | + '<br />' . |
| 221 | + Html::input( |
| 222 | + '', |
| 223 | + wfMsg( 'livetranslate-special-button' ), |
| 224 | + 'submit', |
| 225 | + array( 'id' => 'tmform-submit' ) |
| 226 | + ) . |
| 227 | + Html::hidden( 'wpEditToken', $wgUser->editToken() ) . |
| 228 | + Html::closeElement( 'form' ) |
| 229 | + ); |
| 230 | + } |
| 231 | + |
| 232 | + /** |
| 233 | + * Displays a single row in the translation memories config table. |
| 234 | + * |
| 235 | + * @since 0.4 |
| 236 | + * |
| 237 | + * @return array |
| 238 | + */ |
| 239 | + protected function getTMConfigItems() { |
| 240 | + $dbr = wfGetDB( DB_SLAVE ); |
| 241 | + |
| 242 | + $res = $dbr->select( |
| 243 | + 'live_translate_memories', |
| 244 | + array( 'memory_id', 'memory_type', 'memory_location', 'memory_local' ), |
| 245 | + array(), |
| 246 | + __METHOD__, |
| 247 | + array( 'LIMIT' => '5000' ) |
| 248 | + ); |
| 249 | + |
| 250 | + $tms = array(); |
| 251 | + |
| 252 | + // Iterate over the result items in the result wrapper to end up with a regular array. |
| 253 | + foreach ( $res as $tm ) { |
| 254 | + $tms[] = $tm; |
| 255 | + } |
| 256 | + |
| 257 | + return $tms; |
| 258 | + } |
| 259 | + |
| 260 | + /** |
| 261 | + * Displays a single row in the translation memories config table. |
| 262 | + * |
| 263 | + * @since 0.4 |
| 264 | + * |
| 265 | + * @param object $tm |
| 266 | + */ |
| 267 | + protected function displayTMItem( $tm ) { |
| 268 | + global $wgOut; |
| 269 | + |
| 270 | + $wgOut->addHTML( Html::rawElement( |
| 271 | + 'tr', |
| 272 | + array(), |
| 273 | + Html::rawElement( |
| 274 | + 'td', |
| 275 | + array(), |
| 276 | + Html::input( 'tmlocation-' . $tm->memory_id, $tm->memory_location, 'text', array( 'size' => 60 ) ) |
| 277 | + ) . |
| 278 | + Html::rawElement( |
| 279 | + 'td', |
| 280 | + array(), |
| 281 | + $this->getTypeSelector( 'tmtype-' . $tm->memory_id, $tm->memory_type ) |
| 282 | + ) . |
| 283 | + Html::rawElement( |
| 284 | + 'td', |
| 285 | + array( 'style' => 'text-align:center' ), |
| 286 | + Xml::check( 'tmlocal-' . $tm->memory_id, $tm->memory_local != "0" ) |
| 287 | + ) . |
| 288 | + Html::rawElement( |
| 289 | + 'td', |
| 290 | + array( 'style' => 'text-align:center' ), |
| 291 | + Xml::check( 'tmdel-' . $tm->memory_id, false ) |
| 292 | + ) |
| 293 | + ) ); |
| 294 | + } |
| 295 | + |
| 296 | + /** |
| 297 | + * Displays an input to add a new translation memory. |
| 298 | + * |
| 299 | + * @since 0.4 |
| 300 | + */ |
| 301 | + protected function displayAddNewTM() { |
| 302 | + global $wgOut, $egLiveTranslateTMT; |
| 303 | + |
| 304 | + $wgOut->addHTML( '<h3>' . htmlspecialchars( wfMsg( 'livetranslate-special-add-tm' ) ) . '</h3>' ); |
| 305 | + |
| 306 | + $wgOut->addHTML( |
| 307 | + '<table><tr>' . |
| 308 | + '<td><b>' . htmlspecialchars( wfMsg( 'livetranslate-special-type' ) ) . ': </b></td>' . |
| 309 | + '<td>' . $this->getTypeSelector( 'newtm-type', $egLiveTranslateTMT ) . '</td>' . |
| 310 | + '</tr><tr>' . |
| 311 | + '<td><b>' . htmlspecialchars( wfMsg( 'livetranslate-special-location' ) ) . ': </b></td>' . |
| 312 | + '<td>' . Html::input( 'newtm-location', '', 'text', array( 'size' => 75 ) ) . '</td>' . |
| 313 | + '</tr><tr>' . |
| 314 | + '<td><b>' . htmlspecialchars( wfMsg( 'livetranslate-special-local' ) ) . ': </b></td>' . |
| 315 | + '<td>' . Xml::check( 'newtm-local', false ) . '</td>' . |
| 316 | + '</tr></table>' |
| 317 | + ); |
| 318 | + } |
| 319 | + |
| 320 | + /** |
| 321 | + * Builds up an HTML select for translation memory types with the provided name. |
| 322 | + * The value parameter allows setting which item should be selected. |
| 323 | + * |
| 324 | + * @since 0.4 |
| 325 | + * |
| 326 | + * @param string $name |
| 327 | + * @param string $value |
| 328 | + * |
| 329 | + * @return string |
| 330 | + */ |
| 331 | + protected function getTypeSelector( $name, $value ) { |
| 332 | + $typeSelector = new HTMLSelectField( array( |
| 333 | + 'fieldname' => $name, |
| 334 | + 'options' => $this->getTypeOptions() |
| 335 | + ) ); |
| 336 | + |
| 337 | + return $typeSelector->getInputHTML( $value ); |
| 338 | + } |
| 339 | + |
| 340 | + /** |
| 341 | + * Returns an array with the translation memory type names (keys) |
| 342 | + * and their database values (values). |
| 343 | + * |
| 344 | + * @since 0.4 |
| 345 | + * |
| 346 | + * @return array |
| 347 | + */ |
| 348 | + protected function getTypeOptions() { |
| 349 | + static $options = false; |
| 350 | + |
| 351 | + if ( $options === false ) { |
| 352 | + $options = array(); |
| 353 | + |
| 354 | + $tmTypes = array( |
| 355 | + TMT_LTF => 'ltf', |
| 356 | + TMT_TMX => 'tmx', |
| 357 | + TMT_GCSV => 'gcsv', |
| 358 | + ); |
| 359 | + |
| 360 | + foreach ( $tmTypes as $dbValue => $msgKey ) { |
| 361 | + $options[wfMsg( 'livetranslate-tmtype-' . $msgKey )] = $dbValue; |
| 362 | + } |
| 363 | + } |
| 364 | + |
| 365 | + return $options; |
| 366 | + } |
| 367 | + |
| 368 | +} |
Property changes on: tags/extensions/LiveTranslate/REL_0_4/specials/SpecialLiveTranslate.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 369 | + native |
Index: tags/extensions/LiveTranslate/REL_0_4/LiveTranslate.hooks.php |
— | — | @@ -0,0 +1,288 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * Static class for hooks handled by the Live Translate extension. |
| 6 | + * |
| 7 | + * @since 0.1 |
| 8 | + * |
| 9 | + * @file LiveTranslate.hooks.php |
| 10 | + * @ingroup LiveTranslate |
| 11 | + * |
| 12 | + * @author Jeroen De Dauw |
| 13 | + */ |
| 14 | +final class LiveTranslateHooks { |
| 15 | + |
| 16 | + /** |
| 17 | + * Hook to insert things into article headers. |
| 18 | + * |
| 19 | + * @since 0.1 |
| 20 | + * |
| 21 | + * @param Article &$article |
| 22 | + * @param boolean $outputDone |
| 23 | + * @param boolean $useParserCache |
| 24 | + * |
| 25 | + * @return true |
| 26 | + */ |
| 27 | + public static function onArticleViewHeader( Article &$article, &$outputDone, &$useParserCache ) { |
| 28 | + global $egGoogleApiKey, $egLiveTranslateLanguages; |
| 29 | + |
| 30 | + $title = $article->getTitle(); |
| 31 | + |
| 32 | + $currentLang = LiveTranslateFunctions::getCurrentLang( $title ); |
| 33 | + |
| 34 | + // FIXME: Hitting the db on every page load should be avoided |
| 35 | + if ( in_array( $title->getFullText(), LiveTranslateFunctions::getLocalMemoryNames() ) ) { |
| 36 | + self::displayDictionaryPage( $article, $title ); |
| 37 | + $outputDone = true; // The translations themselves should not be shown. |
| 38 | + } |
| 39 | + else if ( |
| 40 | + $egGoogleApiKey != '' |
| 41 | + && $article->exists() |
| 42 | + && ( count( $egLiveTranslateLanguages ) > 1 || ( count( $egLiveTranslateLanguages ) == 1 && $egLiveTranslateLanguages[0] != $currentLang ) ) ) { |
| 43 | + |
| 44 | + self::displayTranslationControl( $currentLang ); |
| 45 | + } |
| 46 | + |
| 47 | + return true; |
| 48 | + } |
| 49 | + |
| 50 | + /** |
| 51 | + * Displays some shorts statistics about the dictionary page. |
| 52 | + * |
| 53 | + * @since 0.4 |
| 54 | + * |
| 55 | + * @param Article $article |
| 56 | + * @param Title $title |
| 57 | + */ |
| 58 | + protected static function displayDictionaryPage( Article &$article, Title $title ) { |
| 59 | + global $wgOut, $wgLang, $wgUser, $egLiveTranslateLanguages; |
| 60 | + |
| 61 | + $dbr = wfGetDb( DB_SLAVE ); |
| 62 | + |
| 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 ) { |
| 78 | + $wgOut->addWikiMsg( 'livetranslate-dictionary-empty' ); |
| 79 | + } |
| 80 | + else { |
| 81 | + $wgOut->addWikiMsg( |
| 82 | + 'livetranslate-dictionary-count', |
| 83 | + $wgLang->formatNum( $tm->memory_tu_count ) , |
| 84 | + $wgLang->formatNum( $tm->memory_lang_count ) |
| 85 | + ); |
| 86 | + |
| 87 | + /* |
| 88 | + $notAllowedLanguages = array(); |
| 89 | + |
| 90 | + foreach ( $tus[0]->getVariants() as $languageCode => $translations ) { |
| 91 | + $languageCode = strtolower( $languageCode ); |
| 92 | + $mappings = LiveTranslateFunctions::getInputLangMapping(); |
| 93 | + |
| 94 | + if ( array_key_exists( $languageCode, $mappings ) ) { |
| 95 | + $languageCode = $mappings[$languageCode]; |
| 96 | + } |
| 97 | + |
| 98 | + if ( !in_array( $languageCode, $egLiveTranslateLanguages ) ) { |
| 99 | + $notAllowedLanguages[] = $languageCode; |
| 100 | + } |
| 101 | + } |
| 102 | + |
| 103 | + if ( count( $notAllowedLanguages ) > 0 ) { |
| 104 | + $languages = Language::getLanguageNames( false ); |
| 105 | + |
| 106 | + foreach ( $notAllowedLanguages as &$notAllowedLang ) { |
| 107 | + if ( array_key_exists( $notAllowedLang, $languages ) ) { |
| 108 | + $notAllowedLang = $languages[$notAllowedLang]; |
| 109 | + } |
| 110 | + } |
| 111 | + |
| 112 | + $wgOut->addHTML( |
| 113 | + Html::element( |
| 114 | + 'span', |
| 115 | + array( 'style' => 'color:darkred' ), |
| 116 | + wfMsgExt( 'livetranslate-dictionary-unallowed-langs', 'parsemag', $wgLang->listToText( $notAllowedLanguages ), count( $notAllowedLanguages ) ) |
| 117 | + ) |
| 118 | + ); |
| 119 | + } |
| 120 | + */ |
| 121 | + } |
| 122 | + |
| 123 | + if ( $wgUser->isAllowed( 'managetms' ) ) { |
| 124 | + $wgOut->addHTML( |
| 125 | + Html::element( |
| 126 | + 'a', |
| 127 | + array( 'href' => Title::newFromText( 'Special:LiveTranslate' )->getInternalURL() ), |
| 128 | + wfMsg( 'livetranslate-dictionary-goto-edit' ) |
| 129 | + ) |
| 130 | + ); |
| 131 | + } |
| 132 | + } |
| 133 | + |
| 134 | + /** |
| 135 | + * Outputs the Live Translate translation control. |
| 136 | + * |
| 137 | + * @since 0.4 |
| 138 | + * |
| 139 | + * @param string $currentLang |
| 140 | + */ |
| 141 | + protected static function displayTranslationControl( $currentLang ) { |
| 142 | + global $wgOut, $egGoogleApiKey; |
| 143 | + |
| 144 | + $wgOut->addHTML( |
| 145 | + Html::rawElement( |
| 146 | + 'div', |
| 147 | + array( |
| 148 | + 'id' => 'livetranslatediv', |
| 149 | + 'style' => 'display:inline; float:right', |
| 150 | + 'class' => 'notranslate' |
| 151 | + ), |
| 152 | + htmlspecialchars( wfMsg( 'livetranslate-translate-to' ) ) . |
| 153 | + ' ' . |
| 154 | + LiveTranslateFunctions::getLanguageSelector( $currentLang ) . |
| 155 | + ' ' . |
| 156 | + Html::element( |
| 157 | + 'button', |
| 158 | + array( 'id' => 'livetranslatebutton' ), |
| 159 | + wfMsg( 'livetranslate-button-translate' ) |
| 160 | + ) . |
| 161 | + ' ' . |
| 162 | + Html::element( |
| 163 | + 'button', |
| 164 | + array( 'id' => 'ltrevertbutton', 'style' => 'display:none' ), |
| 165 | + wfMsg( 'livetranslate-button-revert' ) |
| 166 | + ) |
| 167 | + ) . |
| 168 | + '<br /><br /><div id="googlebranding" style="display:inline; float:right"></div>' |
| 169 | + ); |
| 170 | + |
| 171 | + $wgOut->addScript( |
| 172 | + Html::linkedScript( 'https://www.google.com/jsapi?key=' . htmlspecialchars( $egGoogleApiKey ) ) . |
| 173 | + Html::inlineScript( |
| 174 | + 'google.load("language", "1"); |
| 175 | + google.setOnLoadCallback(function(){google.language.getBranding("googlebranding");});' . |
| 176 | + 'var sourceLang = ' . json_encode( $currentLang ) . ';' |
| 177 | + ) |
| 178 | + ); |
| 179 | + |
| 180 | + LiveTranslateFunctions::loadJs(); |
| 181 | + } |
| 182 | + |
| 183 | + /** |
| 184 | + * Schema update to set up the needed database tables. |
| 185 | + * |
| 186 | + * @since 0.1 |
| 187 | + * |
| 188 | + * @param DatabaseUpdater $updater |
| 189 | + * |
| 190 | + * @return true |
| 191 | + */ |
| 192 | + public static function onSchemaUpdate( /* DatabaseUpdater */ $updater = null ) { |
| 193 | + global $wgDBtype, $egLiveTranslateIP; |
| 194 | + |
| 195 | + if ( $wgDBtype == 'mysql' ) { |
| 196 | + // Set up the current schema. |
| 197 | + if ( $updater === null ) { |
| 198 | + global $wgExtNewTables, $wgExtNewIndexes, $wgExtNewFields; |
| 199 | + |
| 200 | + $wgExtNewTables[] = array( |
| 201 | + 'live_translate', |
| 202 | + $egLiveTranslateIP . '/LiveTranslate.sql', |
| 203 | + true |
| 204 | + ); |
| 205 | + $wgExtNewTables[] = array( |
| 206 | + 'live_translate_memories', |
| 207 | + $egLiveTranslateIP . '/LiveTranslate.sql', |
| 208 | + true |
| 209 | + ); |
| 210 | + |
| 211 | + $wgExtNewIndexes[] = array( |
| 212 | + 'live_translate', |
| 213 | + 'word_translation', |
| 214 | + $egLiveTranslateIP . '/sql/LT_IndexWordTranslation.sql', |
| 215 | + true |
| 216 | + ); |
| 217 | + |
| 218 | + $wgExtNewFields[] = array( |
| 219 | + 'live_translate', |
| 220 | + 'memory_id', |
| 221 | + $egLiveTranslateIP . '/sql/LT_addTMField.sql' |
| 222 | + ); |
| 223 | + } |
| 224 | + else { |
| 225 | + $updater->addExtensionUpdate( array( |
| 226 | + 'addTable', |
| 227 | + 'live_translate', |
| 228 | + $egLiveTranslateIP . '/LiveTranslate.sql', |
| 229 | + true |
| 230 | + ) ); |
| 231 | + $updater->addExtensionUpdate( array( |
| 232 | + 'addTable', |
| 233 | + 'live_translate_memories', |
| 234 | + $egLiveTranslateIP . '/LiveTranslate.sql', |
| 235 | + true |
| 236 | + ) ); |
| 237 | + |
| 238 | + $updater->addExtensionUpdate( array( |
| 239 | + 'addIndex', |
| 240 | + 'live_translate', |
| 241 | + 'word_translation', |
| 242 | + $egLiveTranslateIP . '/sql/LT_IndexWordTranslation.sql', |
| 243 | + true |
| 244 | + ) ); |
| 245 | + |
| 246 | + $updater->addExtensionUpdate( array( |
| 247 | + 'addField', |
| 248 | + 'live_translate', |
| 249 | + 'memory_id', |
| 250 | + $egLiveTranslateIP . '/sql/LT_addTMField.sql', |
| 251 | + true |
| 252 | + ) ); |
| 253 | + } |
| 254 | + } |
| 255 | + |
| 256 | + return true; |
| 257 | + } |
| 258 | + |
| 259 | + /** |
| 260 | + * Handles edits to the dictionary page to save the translations into the db. |
| 261 | + * |
| 262 | + * @since 0.1 |
| 263 | + * |
| 264 | + * @return true |
| 265 | + */ |
| 266 | + public static function onArticleSaveComplete( &$article, &$user, $text, $summary, |
| 267 | + $minoredit, $watchthis, $sectionanchor, &$flags, $revision, &$status, $baseRevId, &$redirect = null ) { |
| 268 | + |
| 269 | + $title = $article->getTitle(); |
| 270 | + |
| 271 | + // FIXME: Hitting the db on every page save should be avoided |
| 272 | + if ( in_array( $title->getFullText(), LiveTranslateFunctions::getLocalMemoryNames() ) ) { |
| 273 | + $requestData = array( |
| 274 | + 'action' => 'importtms', |
| 275 | + 'format' => 'json', |
| 276 | + 'source' => $title->getFullText(), |
| 277 | + 'type' => LiveTranslateFunctions::getMemoryType( $title->getFullText() ), |
| 278 | + 'local' => 1 |
| 279 | + ); |
| 280 | + |
| 281 | + $api = new ApiMain( new FauxRequest( $requestData, true ), true ); |
| 282 | + $api->execute(); |
| 283 | + $response = $api->getResultData(); |
| 284 | + } |
| 285 | + |
| 286 | + return true; |
| 287 | + } |
| 288 | + |
| 289 | +} |
Property changes on: tags/extensions/LiveTranslate/REL_0_4/LiveTranslate.hooks.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 290 | + native |
Index: tags/extensions/LiveTranslate/REL_0_4/INSTALL |
— | — | @@ -0,0 +1,46 @@ |
| 2 | +These is the install file for the Live Translate extension. |
| 3 | + |
| 4 | +Extension page on mediawiki.org: http://www.mediawiki.org/wiki/Extension:Live_Translate |
| 5 | +Latest version of the install file: http://svn.wikimedia.org/viewvc/mediawiki/trunk/extensions/LiveTranslate/INSTALL?view=co |
| 6 | + |
| 7 | + |
| 8 | +== Installation == |
| 9 | + |
| 10 | +Once you have downloaded the code, place the ''LiveTranslate'' directory within your MediaWiki 'extensions' directory. |
| 11 | +Then add the following code to your [[Manual:LocalSettings.php|LocalSettings.php]] file: |
| 12 | + |
| 13 | +# Live Translate |
| 14 | +require_once( "$IP/extensions/LiveTranslate/LiveTranslate.php" ); |
| 15 | + |
| 16 | +After this you need to run MediaWikis update script which can be found at /maintenance/update.php. |
| 17 | + |
| 18 | +After doing this, you have installed the extension. To be able to use it in a meaningful way, you also need to take care of some configuration: |
| 19 | + |
| 20 | +== Configuration == |
| 21 | + |
| 22 | +Configuration of Live Translate is done by adding simple PHP statements to your [[Manual:LocalSettings.php|LocalSettings.php]] |
| 23 | +file. These statements need to be placed AFTER the inclusion of Live Translate. The options are listed below and their default |
| 24 | +is set in the [http://svn.wikimedia.org/viewvc/mediawiki/trunk/extensions/LiveTranslate/LiveTranslate_Settings.php?view=markup Live Translate settings file]. |
| 25 | +You should NOT modify the settings file, but can have a look at it to get an idea of how to use the settings, in case the below descriptions do not suffice. |
| 26 | + |
| 27 | +=== Google API key === |
| 28 | + |
| 29 | +To be able to actually use Google Translate, you need to [https://code.google.com/apis/console get an API key] and |
| 30 | +add it to your [[LocalSettings.php]] file AFTER the inclusion of the extension. |
| 31 | + |
| 32 | +<source lang="php"> |
| 33 | +# Google API key |
| 34 | +$egGoogleApiKey = 'INSERT-YOUR-KEY-HERE'; |
| 35 | +</source> |
| 36 | + |
| 37 | +=== Available languages === |
| 38 | + |
| 39 | +You have to specify which languages users should be able to translate to. This is done by adding language codes to <code>$egLiveTranslateLanguages</code>. |
| 40 | +By default it contains only your wikis main language (as specified by <code>$wgLanguageCode</code> in [[LocalSettings.php]]). You add languages as follows: |
| 41 | + |
| 42 | +<source lang="php"> |
| 43 | +$egLiveTranslateLanguages[] = 'nl'; |
| 44 | +$egLiveTranslateLanguages[] = 'de'; |
| 45 | +</source> |
| 46 | + |
| 47 | +If there are no languages available other then the current language of the page, then the translation control will not show up. |
Index: tags/extensions/LiveTranslate/REL_0_4/RELEASE-NOTES |
— | — | @@ -0,0 +1,38 @@ |
| 2 | +These are the release notes for the Live Translate extension. |
| 3 | + |
| 4 | +Extension page on mediawiki.org: http://www.mediawiki.org/wiki/Extension:Live_Translate |
| 5 | +Latest version of the release notes: http://svn.wikimedia.org/viewvc/mediawiki/trunk/extensions/LiveTranslate/RELEASE-NOTES?view=co |
| 6 | + |
| 7 | + |
| 8 | +=== Version 0.4 === |
| 9 | +2011-01-14 |
| 10 | + |
| 11 | +* Added support for multiple translation memories. |
| 12 | +* Added Special:LiveTranslate to manage the translation memories that should be used. |
| 13 | +* Added support for remote translation memories. |
| 14 | +* Added support for the Translation Memory eXchange (TMX) format. |
| 15 | +* Added Google branding, which is required when using the Google Translate API. |
| 16 | +: https://code.google.com/apis/language/translate/v1/getting_started.html#getBranding |
| 17 | +* Improved translation memory insertion into the database. |
| 18 | +* Added better tracking of translation memory sizes and language counts. |
| 19 | + |
| 20 | +=== Version 0.3 === |
| 21 | +2011-01-07 |
| 22 | + |
| 23 | +* Added (partial) compatibility with IE8. Random errors still occur. Use a modern browser to prevent this. |
| 24 | +* Fixed issue with trim-prevention, causing |-signs to semi-randomly get inserted into translated text. |
| 25 | +* Only show the translation control when an API key is provided. |
| 26 | + |
| 27 | +=== Version 0.2 === |
| 28 | +2010-12-24 |
| 29 | + |
| 30 | +* Fixed installation compatibility issue with MW 1.16. |
| 31 | +* Fixed display of translation control to only happen on existing pages. |
| 32 | +* Fixed issues with inserting notranslatre tags into the page source. |
| 33 | + |
| 34 | +=== Version 0.1 === |
| 35 | +2010-12-22 |
| 36 | + |
| 37 | +* Added simple translation interface to the right top of articles. |
| 38 | +* Implemented translation via the Google Translate API. |
| 39 | +* Added dictionary for special words with synonyms support. |
Index: tags/extensions/LiveTranslate/REL_0_4/includes/LT_TMParser.php |
— | — | @@ -0,0 +1,62 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * Abstract base class for translation memory (TM) parsers. |
| 6 | + * |
| 7 | + * @since 0.4 |
| 8 | + * |
| 9 | + * @file LT_TMParser.php |
| 10 | + * @ingroup LiveTranslate |
| 11 | + * |
| 12 | + * @licence GNU GPL v3 |
| 13 | + * @author Jeroen De Dauw < jeroendedauw@gmail.com > |
| 14 | + */ |
| 15 | +abstract class LTTMParser { |
| 16 | + |
| 17 | + /** |
| 18 | + * Creates a new translation memory parser. |
| 19 | + * |
| 20 | + * @since 0.4 |
| 21 | + */ |
| 22 | + public function __construct() { |
| 23 | + |
| 24 | + } |
| 25 | + |
| 26 | + /** |
| 27 | + * Parses the provided text to a LTTranslationMemory object. |
| 28 | + * |
| 29 | + * @since 0.4 |
| 30 | + * |
| 31 | + * @param string $text |
| 32 | + * |
| 33 | + * @return LTTranslationMemory |
| 34 | + */ |
| 35 | + public abstract function parse( $text ); |
| 36 | + |
| 37 | + /** |
| 38 | + * Retruns a new instance of a parser that implements LTTMParser and can parse |
| 39 | + * translation memories of the provided type. If none is found, an exception is thrown. |
| 40 | + * |
| 41 | + * @since 0.4 |
| 42 | + * |
| 43 | + * @param string $tmType |
| 44 | + * |
| 45 | + * @return LTTMParser |
| 46 | + */ |
| 47 | + public static function newFromType( $tmType ) { |
| 48 | + switch ( $tmType ) { |
| 49 | + case TMT_LTF : |
| 50 | + return new LTLTFParser(); |
| 51 | + break; |
| 52 | + case TMT_TMX : |
| 53 | + return new LTTMXParser(); |
| 54 | + break; |
| 55 | + case TMT_GCSV : |
| 56 | + return new LTGCSVParser(); |
| 57 | + break; |
| 58 | + default : |
| 59 | + throw new MWException( "There is no translation memory parser for translation memories of type '$tmType'." ); |
| 60 | + } |
| 61 | + } |
| 62 | + |
| 63 | +} |
Property changes on: tags/extensions/LiveTranslate/REL_0_4/includes/LT_TMParser.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 64 | + native |
Index: tags/extensions/LiveTranslate/REL_0_4/includes/LT_GCSVParser.php |
— | — | @@ -0,0 +1,24 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * Parser for translation memory data in the Google CSV format (GCSV). |
| 6 | + * |
| 7 | + * @since 0.4 |
| 8 | + * |
| 9 | + * @file LT_GCSVParser.php |
| 10 | + * @ingroup LiveTranslate |
| 11 | + * |
| 12 | + * @licence GNU GPL v3 |
| 13 | + * @author Jeroen De Dauw < jeroendedauw@gmail.com > |
| 14 | + */ |
| 15 | +class LTGCSVParser extends LTTMParser { |
| 16 | + |
| 17 | + /** |
| 18 | + * (non-PHPdoc) |
| 19 | + * @see LTTMParser::parse() |
| 20 | + */ |
| 21 | + public function parse( $text ) { |
| 22 | + return new LTTranslationMemory(); // TODO |
| 23 | + } |
| 24 | + |
| 25 | +} |
Property changes on: tags/extensions/LiveTranslate/REL_0_4/includes/LT_GCSVParser.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 26 | + native |
Index: tags/extensions/LiveTranslate/REL_0_4/includes/LT_TMUnit.php |
— | — | @@ -0,0 +1,143 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * Class describing a single translation memory unit. |
| 6 | + * |
| 7 | + * @since 0.4 |
| 8 | + * |
| 9 | + * @file LT_TMUnit.php |
| 10 | + * @ingroup LiveTranslate |
| 11 | + * |
| 12 | + * @licence GNU GPL v3 |
| 13 | + * @author Jeroen De Dauw < jeroendedauw@gmail.com > |
| 14 | + */ |
| 15 | +class LTTMUnit { |
| 16 | + |
| 17 | + /** |
| 18 | + * List of language varinats of the translation memory unit. |
| 19 | + * |
| 20 | + * language code => array( primary translation [, synonym [, ect]] ) |
| 21 | + * |
| 22 | + * @since 0.4 |
| 23 | + * |
| 24 | + * @var array |
| 25 | + */ |
| 26 | + protected $variants = array(); |
| 27 | + |
| 28 | + /** |
| 29 | + * Creates a new translation memory unit. |
| 30 | + * |
| 31 | + * @since 0.4 |
| 32 | + * |
| 33 | + * @param array $variants |
| 34 | + */ |
| 35 | + public function __construct( array $variants = array() ) { |
| 36 | + $this->addVariants( $variants ); |
| 37 | + } |
| 38 | + |
| 39 | + /** |
| 40 | + * Returns the list of language varinats of the translation memory unit. |
| 41 | + * |
| 42 | + * @since 0.4 |
| 43 | + * |
| 44 | + * @var array: language code => array( primary translation [, synonym [, ect]] ) |
| 45 | + */ |
| 46 | + public function getVariants() { |
| 47 | + return $this->variants; |
| 48 | + } |
| 49 | + |
| 50 | + /** |
| 51 | + * Adds the translation (and optional synonyms) of the unit in a single language. |
| 52 | + * |
| 53 | + * @since 0.4 |
| 54 | + * |
| 55 | + * @param string $language |
| 56 | + * @param string $translation |
| 57 | + * @param array $synonyms |
| 58 | + */ |
| 59 | + public function addVariant( $language, $translation, array $synonyms = array() ) { |
| 60 | + $this->variants[$language] = array_merge( array( $translation ), $synonyms ); |
| 61 | + } |
| 62 | + |
| 63 | + /** |
| 64 | + * Adds a list of translations to the translation memory unit. |
| 65 | + * |
| 66 | + * @since 0.4 |
| 67 | + * |
| 68 | + * @param array $variants language code => array( primary translation [, synonym [, ect]] ) |
| 69 | + */ |
| 70 | + public function addVariants( array $variants ) { |
| 71 | + foreach ( $variants as $language => $variant ) { |
| 72 | + $variant = (array)$variant; // Do not require an array, to simplify notation when there are no synonyms. |
| 73 | + $primaryTranslation = array_shift( $variant ); |
| 74 | + $this->addVariant( $language, $primaryTranslation, $variant ); |
| 75 | + } |
| 76 | + } |
| 77 | + |
| 78 | + /** |
| 79 | + * Returns if the translation unit has any variants. If not, it can probably be ignored. |
| 80 | + * |
| 81 | + * @since 0.4 |
| 82 | + * |
| 83 | + * @return boolean |
| 84 | + */ |
| 85 | + public function hasVariants() { |
| 86 | + return count( $this->variants ) > 0; |
| 87 | + } |
| 88 | + |
| 89 | + /** |
| 90 | + * Returns if the translation unit has any significant value. This means it has at least 2 |
| 91 | + * variants with different values. |
| 92 | + * |
| 93 | + * @since 0.4 |
| 94 | + * |
| 95 | + * @return boolean |
| 96 | + */ |
| 97 | + public function isSignificant() { |
| 98 | + return count( $this->variants ) > 1 && $this->hasVariantDifferences(); |
| 99 | + } |
| 100 | + |
| 101 | + /** |
| 102 | + * Returns if the translation unit has a certain minimal amount (default: 1) of |
| 103 | + * differences in values in it's variants. |
| 104 | + * |
| 105 | + * @since 0.4 |
| 106 | + * |
| 107 | + * @return boolean |
| 108 | + */ |
| 109 | + public function hasVariantDifferences( $minAmount = 1 ) { |
| 110 | + $amount = -1; // The first unknown value is not a difference. |
| 111 | + $knownValues = array(); |
| 112 | + |
| 113 | + foreach ( $this->variants as $variant ) { |
| 114 | + // If the value is not known yet, it's a difference. |
| 115 | + if ( !in_array( $variant[0], $knownValues ) ) { |
| 116 | + $knownValues[] = $variant[0]; |
| 117 | + $amount++; |
| 118 | + } |
| 119 | + // If there are synonyms, just assume it's different. |
| 120 | + // This might not be the case, but no full accuracy is required. |
| 121 | + else if ( count( $variant ) > 1 ) { |
| 122 | + $amount++; |
| 123 | + } |
| 124 | + |
| 125 | + if ( $amount >= $minAmount ) { |
| 126 | + return true; |
| 127 | + } |
| 128 | + } |
| 129 | + |
| 130 | + return false; |
| 131 | + } |
| 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 | + |
| 144 | +} |
Property changes on: tags/extensions/LiveTranslate/REL_0_4/includes/LT_TMUnit.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 145 | + native |
Index: tags/extensions/LiveTranslate/REL_0_4/includes/LT_LTFParser.php |
— | — | @@ -0,0 +1,45 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * Parser for custom Live Translate translation memory Format (LFT) data. |
| 6 | + * |
| 7 | + * @since 0.4 |
| 8 | + * |
| 9 | + * @file LT_LTFParser.php |
| 10 | + * @ingroup LiveTranslate |
| 11 | + * |
| 12 | + * @licence GNU GPL v3 |
| 13 | + * @author Jeroen De Dauw < jeroendedauw@gmail.com > |
| 14 | + */ |
| 15 | +class LTLTFParser extends LTTMParser { |
| 16 | + |
| 17 | + /** |
| 18 | + * (non-PHPdoc) |
| 19 | + * @see LTTMParser::parse() |
| 20 | + */ |
| 21 | + public function parse( $text ) { |
| 22 | + $tm = new LTTranslationMemory(); |
| 23 | + |
| 24 | + $translationSets = array(); |
| 25 | + |
| 26 | + $lines = explode( "\n", $text ); |
| 27 | + $languages = array_map( 'trim', explode( ',', array_shift( $lines ) ) ); |
| 28 | + |
| 29 | + foreach ( $lines as $line ) { |
| 30 | + $values = array_map( 'trim', explode( ',', $line ) ); |
| 31 | + $tu = new LTTMUnit(); |
| 32 | + |
| 33 | + foreach ( $values as $nr => $value ) { |
| 34 | + if ( array_key_exists( $nr, $languages ) ) { |
| 35 | + // Add the translation (or translations) (value, array) of the word in the language (key). |
| 36 | + $tu->addVariants( array( $languages[$nr] => array_map( 'trim', explode( '|', $value ) ) ) ); |
| 37 | + } |
| 38 | + } |
| 39 | + |
| 40 | + $tm->addTranslationUnit( $tu ); |
| 41 | + } |
| 42 | + |
| 43 | + return $tm; |
| 44 | + } |
| 45 | + |
| 46 | +} |
\ No newline at end of file |
Property changes on: tags/extensions/LiveTranslate/REL_0_4/includes/LT_LTFParser.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 47 | + native |
Index: tags/extensions/LiveTranslate/REL_0_4/includes/ext.livetranslate.js |
— | — | @@ -0,0 +1,341 @@ |
| 2 | +/** |
| 3 | + * JavasSript for the Live Translate extension. |
| 4 | + * @see http://www.mediawiki.org/wiki/Extension:Live_Translate |
| 5 | + * |
| 6 | + * @author Jeroen De Dauw <jeroendedauw at gmail dot com> |
| 7 | + */ |
| 8 | + |
| 9 | +(function($) { $( document ).ready( function() { |
| 10 | + |
| 11 | + /* |
| 12 | + * jQuery replaceText - v1.1 - 11/21/2009 |
| 13 | + * http://benalman.com/projects/jquery-replacetext-plugin/ |
| 14 | + * |
| 15 | + * Copyright (c) 2009 "Cowboy" Ben Alman |
| 16 | + * Dual licensed under the MIT and GPL licenses. |
| 17 | + * http://benalman.com/about/license/ |
| 18 | + */ |
| 19 | + $.fn.replaceText=function(b,a,c){return this.each(function(){var f=this.firstChild,g,e,d=[];if(f){do{if(f.nodeType===3){g=f.nodeValue;e=g.replace(b,a);if(e!==g){if(!c&&/</.test(e)){$(f).before(e);d.push(f)}else{f.nodeValue=e}}}}while(f=f.nextSibling)}d.length&&$(d).remove()})} |
| 20 | + |
| 21 | + var currentLang = window.sourceLang; |
| 22 | + |
| 23 | + var runningJobs = 0; |
| 24 | + |
| 25 | + // This is to enable a hack to decode quotes. |
| 26 | + var textAreaElement = document.createElement( 'textarea' ); |
| 27 | + |
| 28 | + // For the "show original" feature. |
| 29 | + var originalHtml = false; |
| 30 | + |
| 31 | + // Compatibility with pre-RL code. |
| 32 | + // Messages will have been loaded into wgPushMessages. |
| 33 | + if ( typeof mediaWiki === 'undefined' ) { |
| 34 | + mediaWiki = new Object(); |
| 35 | + |
| 36 | + mediaWiki.msg = function() { |
| 37 | + message = window.wgLTEMessages[arguments[0]]; |
| 38 | + |
| 39 | + for ( var i = arguments.length - 1; i > 0; i-- ) { |
| 40 | + message = message.replace( '$' + i, arguments[i] ); |
| 41 | + } |
| 42 | + |
| 43 | + return message; |
| 44 | + } |
| 45 | + } |
| 46 | + |
| 47 | + /** |
| 48 | + * Queries the special words in the source language, finds them in the page, |
| 49 | + * and wraps the into notranslate spans. Then initiates the translation process. |
| 50 | + */ |
| 51 | + setupTranslationFeatures = function() { |
| 52 | + $( this ).attr( "disabled", true ).text( mediaWiki.msg( 'livetranslate-button-translating' ) ); |
| 53 | + |
| 54 | + if ( originalHtml === false ) { |
| 55 | + $.getJSON( |
| 56 | + wgScriptPath + '/api.php', |
| 57 | + { |
| 58 | + 'action': 'query', |
| 59 | + 'format': 'json', |
| 60 | + 'list': 'livetranslate', |
| 61 | + 'ltlanguage': currentLang |
| 62 | + }, |
| 63 | + function( data ) { |
| 64 | + if ( data.words ) { |
| 65 | + insertNoTranslateTags( data.words ); |
| 66 | + } |
| 67 | + else if ( data.error && data.error.info ) { |
| 68 | + alert( data.error.info ); |
| 69 | + } |
| 70 | + else { |
| 71 | + for ( i in data ) { |
| 72 | + alert( mediaWiki.msg( 'livetranslate-dictionary-error' ) ); |
| 73 | + break; |
| 74 | + } |
| 75 | + } |
| 76 | + |
| 77 | + originalHtml = $( '#bodyContent' ).html(); |
| 78 | + |
| 79 | + initiateTranslating(); |
| 80 | + } |
| 81 | + ); |
| 82 | + } |
| 83 | + else { |
| 84 | + initiateTranslating(); |
| 85 | + } |
| 86 | + } |
| 87 | + |
| 88 | + /** |
| 89 | + * Initiates the translation process. |
| 90 | + * First all special words are found and send to the local API, |
| 91 | + * and then replaced by their translation in the response. Then |
| 92 | + * the Google Translate translation is initiated. |
| 93 | + */ |
| 94 | + function initiateTranslating() { |
| 95 | + var words = getSpecialWords(); |
| 96 | + var newLang = $( '#livetranslatelang' ).val(); |
| 97 | + |
| 98 | + if ( words.length == 0 ) { |
| 99 | + requestGoogleTranslate( currentLang, newLang ); |
| 100 | + } |
| 101 | + else { |
| 102 | + $.getJSON( |
| 103 | + wgScriptPath + '/api.php', |
| 104 | + { |
| 105 | + 'action': 'livetranslate', |
| 106 | + 'format': 'json', |
| 107 | + 'from': currentLang, |
| 108 | + 'to': newLang, |
| 109 | + 'words': words.join( '|' ) |
| 110 | + }, |
| 111 | + function( data ) { |
| 112 | + if ( data.translations ) { |
| 113 | + replaceSpecialWords( data.translations ); |
| 114 | + } |
| 115 | + requestGoogleTranslate( currentLang, newLang ); |
| 116 | + } |
| 117 | + ); |
| 118 | + } |
| 119 | + } |
| 120 | + |
| 121 | + /** |
| 122 | + * Shows the original page content, simply by setting the html to a stored copy of the original. |
| 123 | + * Also re-binds the jQuery events, as they get lost when doing the html replace. |
| 124 | + */ |
| 125 | + showOriginal = function() { |
| 126 | + currentLang = window.sourceLang; |
| 127 | + $( '#bodyContent' ).html( originalHtml ); |
| 128 | + $( '#livetranslatebutton' ).attr( "disabled", false ).text( mediaWiki.msg( 'livetranslate-button-translate' ) ); |
| 129 | + $( '#livetranslatebutton' ).click( setupTranslationFeatures ); |
| 130 | + $( '#ltrevertbutton' ).click( showOriginal ); |
| 131 | + } |
| 132 | + |
| 133 | + // Initial binding of the button click events. |
| 134 | + $( '#livetranslatebutton' ).click( setupTranslationFeatures ); |
| 135 | + $( '#ltrevertbutton' ).click( showOriginal ); |
| 136 | + |
| 137 | + /** |
| 138 | + * Inserts notranslate spans around the words specified in the passed array in the page content. |
| 139 | + * |
| 140 | + * @param {Array} words |
| 141 | + */ |
| 142 | + function insertNoTranslateTags( words ) { |
| 143 | + for ( i in words ) { |
| 144 | + $( '#bodyContent *' ).replaceText( |
| 145 | + new RegExp( "\\b" + words[i] + "\\b", "g" ), |
| 146 | + function( str ) { |
| 147 | + return '<span class="notranslate">' + str + '</span>' |
| 148 | + } |
| 149 | + ); |
| 150 | + } |
| 151 | + } |
| 152 | + |
| 153 | + /** |
| 154 | + * Finds the special words in the page contents by getting the contents of all |
| 155 | + * notranslate spans and pushing them onto an array. |
| 156 | + * |
| 157 | + * @returns {Array} |
| 158 | + */ |
| 159 | + function getSpecialWords() { |
| 160 | + var words = []; |
| 161 | + |
| 162 | + $.each($( 'span.notranslate' ), function( i, v ) { |
| 163 | + words.push( $(v).text() ); |
| 164 | + }); |
| 165 | + |
| 166 | + return words; |
| 167 | + } |
| 168 | + |
| 169 | + /** |
| 170 | + * Replaced the special words in the page content by looping over them, |
| 171 | + * and checking if there is a matching translation in the provided object. |
| 172 | + * |
| 173 | + * @param {object} translations |
| 174 | + */ |
| 175 | + function replaceSpecialWords( translations ) { |
| 176 | + $.each($("span.notranslate"), function(i,v) { |
| 177 | + var currentText = $(v).text(); |
| 178 | + if ( translations[currentText] ) { |
| 179 | + $(v).text( translations[currentText] ); |
| 180 | + } |
| 181 | + }); |
| 182 | + } |
| 183 | + |
| 184 | + /** |
| 185 | + * Initiates the Google Translate translation. |
| 186 | + * |
| 187 | + * @param {string} sourceLang |
| 188 | + * @param {string} targetLang |
| 189 | + */ |
| 190 | + function requestGoogleTranslate( sourceLang, targetLang ) { |
| 191 | + translateElement( $( '#bodyContent' ), sourceLang, targetLang ); |
| 192 | + } |
| 193 | + |
| 194 | + /** |
| 195 | + * Translates a single DOM element using Google Translate. |
| 196 | + * Loops through child elements and recursivly calls itself to translate these. |
| 197 | + * |
| 198 | + * TODO: be smarter with the requests, and make sure they don't get broken up unecesarrily. |
| 199 | + * |
| 200 | + * @param {jQuery} element |
| 201 | + * @param {string} sourceLang |
| 202 | + * @param {string} targetLang |
| 203 | + */ |
| 204 | + function translateElement( element, sourceLang, targetLang ) { |
| 205 | + runningJobs++; |
| 206 | + |
| 207 | + var maxChunkLength = 500; |
| 208 | + |
| 209 | + element.contents().each( function() { |
| 210 | + // If it's a text node, then translate it. |
| 211 | + if ( this.nodeType == 3 && this.data != undefined && jQuery.trim( this.data ).length > 0 ) { |
| 212 | + runningJobs++; |
| 213 | + translateChunk( |
| 214 | + this.data.split( new RegExp( "(\\S.+?[.!?])(?=\\s+|$)", "gi" ) ), |
| 215 | + [], |
| 216 | + maxChunkLength, |
| 217 | + sourceLang, |
| 218 | + targetLang, |
| 219 | + this |
| 220 | + ); |
| 221 | + } |
| 222 | + // If it's an html element, check to see if it should be ignored, and if not, apply function again. |
| 223 | + else if ( $.inArray( $( this ).attr( 'id' ), [ 'siteSub', 'jump-to-nav' ] ) == -1 |
| 224 | + && !$( this ).hasClass( 'notranslate' ) && !$( this ).hasClass( 'printfooter' ) |
| 225 | + && $( this ).text().length > 0 ) { |
| 226 | + |
| 227 | + translateElement( $( this ), sourceLang, targetLang ); |
| 228 | + } |
| 229 | + } ); |
| 230 | + |
| 231 | + handleTranslationCompletion( targetLang ); |
| 232 | + } |
| 233 | + |
| 234 | + /** |
| 235 | + * Determines a chunk to translate of an DOM elements contents and calls the Google Translate API. |
| 236 | + * Then calls itself if there is any remaining work to be done. |
| 237 | + * |
| 238 | + * @param {array} untranslatedsentences |
| 239 | + * @param {array} chunks |
| 240 | + * @param {integer} currentMaxSize |
| 241 | + * @param {string} sourceLang |
| 242 | + * @param {string} targetLang |
| 243 | + * @param {jQuery} element |
| 244 | + */ |
| 245 | + function translateChunk( untranslatedsentences, chunks, currentMaxSize, sourceLang, targetLang, element ) { |
| 246 | + var remainingPart = false; |
| 247 | + var partToUse = false; |
| 248 | + var sentenceCount = 0; |
| 249 | + var currentLength = 0; |
| 250 | + |
| 251 | + // Find the scentances that can be put in the current chunk. |
| 252 | + for ( i in untranslatedsentences ) { |
| 253 | + sentenceCount++; |
| 254 | + |
| 255 | + if ( currentLength + untranslatedsentences[i].length < currentMaxSize ) { |
| 256 | + currentLength += untranslatedsentences[i].length; |
| 257 | + } |
| 258 | + else if ( untranslatedsentences[i].length > 0 ) { |
| 259 | + if ( currentLength == 0 ) { |
| 260 | + // If the first scentance is longer then the max chunk legth, split it. |
| 261 | + partToUse = untranslatedsentences[i].substr( 0, currentMaxSize - currentLength ); |
| 262 | + remainingPart = untranslatedsentences[i].substr( currentMaxSize - currentLength ); |
| 263 | + } |
| 264 | + |
| 265 | + break; |
| 266 | + } |
| 267 | + } |
| 268 | + |
| 269 | + var chunk = ''; |
| 270 | + |
| 271 | + // Build the chunck. |
| 272 | + for ( i = 0; i < sentenceCount; i++ ) { |
| 273 | + var part = untranslatedsentences.shift(); |
| 274 | + |
| 275 | + if ( i != sentenceCount - 1 || partToUse === false ) { |
| 276 | + chunk += part; |
| 277 | + } |
| 278 | + } |
| 279 | + |
| 280 | + // If there is a remaining part, re-add it to the scentances to translate list. |
| 281 | + if ( remainingPart !== false ) { |
| 282 | + untranslatedsentences.unshift( remainingPart ); |
| 283 | + } |
| 284 | + |
| 285 | + // If there is a partial scentance, add it to the chunk. |
| 286 | + if ( partToUse !== false ) { |
| 287 | + chunk += partToUse; |
| 288 | + } |
| 289 | + |
| 290 | + // If the lenght is 0, the element has been translated. |
| 291 | + if ( chunk.length == 0 ) { |
| 292 | + handleTranslationCompletion( targetLang ); |
| 293 | + return; |
| 294 | + } |
| 295 | + |
| 296 | + // Keep track of leading and tailing spaces, as they often get modified by the GT API. |
| 297 | + var leadingSpace = chunk.substr( 0, 1 ) == ' ' ? ' ' : ''; |
| 298 | + var tailingSpace = ( chunk.length > 1 && chunk.substr( chunk.length - 1, 1 ) == ' ' ) ? ' ' : ''; |
| 299 | + |
| 300 | + google.language.translate( |
| 301 | + jQuery.trim( chunk ), // Trim, so the result does not contain preceding or tailing spaces. |
| 302 | + sourceLang, |
| 303 | + targetLang, |
| 304 | + function(result) { |
| 305 | + if ( result.translation ) { |
| 306 | + chunks.push( leadingSpace + result.translation + tailingSpace ); |
| 307 | + } |
| 308 | + else { |
| 309 | + // If the translation failed, keep the original text. |
| 310 | + chunks.push( chunk ); |
| 311 | + } |
| 312 | + |
| 313 | + if ( untranslatedsentences.length == 0 ) { |
| 314 | + // If the current chunk was smaller then the max size, node translation is complete, so update text. |
| 315 | + textAreaElement.innerHTML = chunks.join(); // This is a hack to decode quotes. |
| 316 | + element.replaceData( 0, element.length, textAreaElement.value ); |
| 317 | + handleTranslationCompletion( targetLang ); |
| 318 | + } |
| 319 | + else { |
| 320 | + // If there is more work to do, move on to the next chunk. |
| 321 | + translateChunk( untranslatedsentences, chunks, currentMaxSize, sourceLang, targetLang, element ); |
| 322 | + } |
| 323 | + } |
| 324 | + ); |
| 325 | + } |
| 326 | + |
| 327 | + /** |
| 328 | + * Should be called every time a DOM element has been translated. |
| 329 | + * By use of the runningJobs var, completion of the translation process is detected, |
| 330 | + * and further handled by this function. |
| 331 | + * |
| 332 | + * @param {string} targetLang |
| 333 | + */ |
| 334 | + function handleTranslationCompletion( targetLang ) { |
| 335 | + if ( !--runningJobs ) { |
| 336 | + currentLang = targetLang; |
| 337 | + $( '#livetranslatebutton' ).attr( "disabled", false ).text( mediaWiki.msg( 'livetranslate-button-translate' ) ); |
| 338 | + $( '#ltrevertbutton' ).css( 'display', 'inline' ); |
| 339 | + } |
| 340 | + } |
| 341 | + |
| 342 | +} ); })(jQuery); |
\ No newline at end of file |
Property changes on: tags/extensions/LiveTranslate/REL_0_4/includes/ext.livetranslate.js |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 343 | + native |
Index: tags/extensions/LiveTranslate/REL_0_4/includes/LT_TMXParser.php |
— | — | @@ -0,0 +1,195 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * Parser for translation memory exchange (TXM) data. |
| 6 | + * |
| 7 | + * @since 0.4 |
| 8 | + * |
| 9 | + * @file LT_TMXParser.php |
| 10 | + * @ingroup LiveTranslate |
| 11 | + * |
| 12 | + * @licence GNU GPL v3 |
| 13 | + * @author Jeroen De Dauw < jeroendedauw@gmail.com > |
| 14 | + * @author Nicola Asuni < http://evolt.org/node/60511 > |
| 15 | + */ |
| 16 | +class LTTMXParser extends LTTMParser { |
| 17 | + |
| 18 | + /** |
| 19 | + * XML parser object. |
| 20 | + * |
| 21 | + * @since 0.4 |
| 22 | + * |
| 23 | + * @var resource |
| 24 | + */ |
| 25 | + protected $parser; |
| 26 | + |
| 27 | + /** |
| 28 | + * The translation memory the parser will store translations in before returning them. |
| 29 | + * |
| 30 | + * @since 0.4 |
| 31 | + * |
| 32 | + * @var LTTranslationMemory |
| 33 | + */ |
| 34 | + protected $tm; |
| 35 | + |
| 36 | + /** |
| 37 | + * The current translation unit. |
| 38 | + * |
| 39 | + * @since 0.4 |
| 40 | + * |
| 41 | + * @var LTTMUnit |
| 42 | + */ |
| 43 | + protected $tu; |
| 44 | + |
| 45 | + /** |
| 46 | + * The language of the current translation unit variant (tuv) node. |
| 47 | + * |
| 48 | + * @since 0.4 |
| 49 | + * |
| 50 | + * @var string |
| 51 | + */ |
| 52 | + protected $currentLanguage; |
| 53 | + |
| 54 | + /** |
| 55 | + * A string to build up translations when a single variant contains multiple segments. |
| 56 | + * |
| 57 | + * @since 0.4 |
| 58 | + * |
| 59 | + * @var string |
| 60 | + */ |
| 61 | + protected $currentTranslation; |
| 62 | + |
| 63 | + /** |
| 64 | + * Boolean to keep track of if the XML parser is inside a segment node. |
| 65 | + * |
| 66 | + * @since 0.4 |
| 67 | + * |
| 68 | + * @var boolean |
| 69 | + */ |
| 70 | + protected $insideSegment; |
| 71 | + |
| 72 | + /** |
| 73 | + * Boolean to keep track of if the XML parser is inside a node that should be ingored. |
| 74 | + * |
| 75 | + * @since 0.4 |
| 76 | + * |
| 77 | + * @var boolean |
| 78 | + */ |
| 79 | + protected $insideIgnoreNode; |
| 80 | + |
| 81 | + /** |
| 82 | + * Constructor. |
| 83 | + * |
| 84 | + * @since 0.4 |
| 85 | + */ |
| 86 | + public function __construct() { |
| 87 | + parent::__construct(); |
| 88 | + |
| 89 | + $this->parser = xml_parser_create(); |
| 90 | + |
| 91 | + xml_parser_set_option( $this->parser, XML_OPTION_CASE_FOLDING, 0 ); |
| 92 | + |
| 93 | + xml_set_object( $this->parser, $this ); |
| 94 | + xml_set_element_handler( $this->parser, "startElementHandler", "endElementHandler" ); |
| 95 | + xml_set_character_data_handler( $this->parser, "segmentContentHandler" ); |
| 96 | + } |
| 97 | + |
| 98 | + /** |
| 99 | + * Destructor. |
| 100 | + * |
| 101 | + * @since 0.4 |
| 102 | + */ |
| 103 | + public function __destruct() { |
| 104 | + xml_parser_free( $this->parser ); |
| 105 | + } |
| 106 | + |
| 107 | + /** |
| 108 | + * (non-PHPdoc) |
| 109 | + * @see LTTMParser::parse() |
| 110 | + */ |
| 111 | + public function parse( $text ) { |
| 112 | + $this->tm = new LTTranslationMemory(); |
| 113 | + |
| 114 | + // Attempt to parse the TMX. |
| 115 | + if( !xml_parse( $this->parser, $text ) ) { |
| 116 | + // xml_error_string(xml_get_error_code($this->parser)) |
| 117 | + // xml_get_current_line_number($this->parser)) |
| 118 | + } |
| 119 | + |
| 120 | + return $this->tm; |
| 121 | + } |
| 122 | + |
| 123 | + /** |
| 124 | + * Sets the start element handler function for the XML parser parser.start_element_handler. |
| 125 | + * |
| 126 | + * @param resource $parser The first parameter, parser, is a reference to the XML parser calling the handler. |
| 127 | + * @param string $name The second parameter, name, contains the name of the element for which this handler is called. If case-folding is in effect for this parser, the element name will be in uppercase letters. |
| 128 | + * @param array $attribs The third parameter, attribs, contains an associative array with the element's attributes (if any). The keys of this array are the attribute names, the values are the attribute values. Attribute names are case-folded on the same criteria as element names. Attribute values are not case-folded. The original order of the attributes can be retrieved by walking through attribs the normal way, using each(). The first key in the array was the first attribute, and so on. |
| 129 | + */ |
| 130 | + protected function startElementHandler( $parser, $name, $attribs ) { |
| 131 | + switch( strtolower( $name ) ) { |
| 132 | + case 'tu': |
| 133 | + // A new translation unit node has been entered, so create a new translation unit object. |
| 134 | + $this->tu = new LTTMUnit(); |
| 135 | + break; |
| 136 | + case 'tuv': |
| 137 | + if ( array_key_exists( 'xml:lang', $attribs ) ) { |
| 138 | + $this->currentLanguage = $attribs['xml:lang']; |
| 139 | + } |
| 140 | + else { |
| 141 | + // TODO: ignore node or give warning |
| 142 | + } |
| 143 | + break; |
| 144 | + case 'seg': |
| 145 | + $this->currentTranslation = ''; |
| 146 | + $this->insideSegment = true; |
| 147 | + break; |
| 148 | + case 'ut' : |
| 149 | + $this->insideIgnoreNode = true; |
| 150 | + break; |
| 151 | + } |
| 152 | + } |
| 153 | + |
| 154 | + /** |
| 155 | + * Sets the end element handler function for the XML parser parser.end_element_handler. |
| 156 | + * |
| 157 | + * @since 0.4 |
| 158 | + * |
| 159 | + * @param resource $parser The first parameter, parser, is a reference to the XML parser calling the handler. |
| 160 | + * @param string $name The second parameter, name, contains the name of the element for which this handler is called. If case-folding is in effect for this parser, the element name will be in uppercase letters. |
| 161 | + */ |
| 162 | + protected function endElementHandler($parser, $name) { |
| 163 | + switch( strtolower( $name ) ) { |
| 164 | + case 'tu': |
| 165 | + // We are leaving the translation unit node, so add the translation unit to the translation memory. |
| 166 | + if ( $this->tu->hasVariants() ) { |
| 167 | + $this->tm->addTranslationUnit( $this->tu ); |
| 168 | + } |
| 169 | + break; |
| 170 | + case 'tuv': |
| 171 | + $this->tu->addVariant( $this->currentLanguage, $this->currentTranslation ); |
| 172 | + break; |
| 173 | + case 'seg': |
| 174 | + $this->insideSegment = false; |
| 175 | + break; |
| 176 | + case 'ut' : |
| 177 | + $this->insideIgnoreNode = false; |
| 178 | + break; |
| 179 | + } |
| 180 | + } |
| 181 | + |
| 182 | + /** |
| 183 | + * Sets the character data handler function for the XML parser parser.handler. |
| 184 | + * |
| 185 | + * @since 0.4 |
| 186 | + * |
| 187 | + * @param resource $parser The first parameter, parser, is a reference to the XML parser calling the handler. |
| 188 | + * @param string $data The second parameter, data, contains the character data as a string. |
| 189 | + */ |
| 190 | + protected function segmentContentHandler( $parser, $data ) { |
| 191 | + if ( $this->insideSegment && !$this->insideIgnoreNode ) { |
| 192 | + $this->currentTranslation .= $data; |
| 193 | + } |
| 194 | + } |
| 195 | + |
| 196 | +} |
Property changes on: tags/extensions/LiveTranslate/REL_0_4/includes/LT_TMXParser.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 197 | + native |
Index: tags/extensions/LiveTranslate/REL_0_4/includes/LiveTranslate_Functions.php |
— | — | @@ -0,0 +1,402 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * Statis class with utility methods for the Live Translate extension. |
| 6 | + * |
| 7 | + * @since 0.1 |
| 8 | + * |
| 9 | + * @file LiveTranslate_Functions.php |
| 10 | + * @ingroup LiveTranslate |
| 11 | + * |
| 12 | + * @author Jeroen De Dauw < jeroendedauw@gmail.com > |
| 13 | + */ |
| 14 | +final class LiveTranslateFunctions { |
| 15 | + |
| 16 | + /** |
| 17 | + * Loads the needed JavaScript. |
| 18 | + * Takes care of non-RL compatibility. |
| 19 | + * |
| 20 | + * @since 0.1 |
| 21 | + */ |
| 22 | + public static function loadJs() { |
| 23 | + global $wgOut; |
| 24 | + |
| 25 | + // For backward compatibility with MW < 1.17. |
| 26 | + if ( is_callable( array( $wgOut, 'addModules' ) ) ) { |
| 27 | + $wgOut->addModules( 'ext.livetranslate' ); |
| 28 | + } |
| 29 | + else { |
| 30 | + global $egLiveTranslateScriptPath; |
| 31 | + |
| 32 | + self::addJSLocalisation(); |
| 33 | + |
| 34 | + $wgOut->includeJQuery(); |
| 35 | + |
| 36 | + $wgOut->addHeadItem( |
| 37 | + 'ext.livetranslate', |
| 38 | + Html::linkedScript( $egLiveTranslateScriptPath . '/includes/ext.livetranslate.js' ) |
| 39 | + ); |
| 40 | + } |
| 41 | + } |
| 42 | + |
| 43 | + /** |
| 44 | + * Adds the needed JS messages to the page output. |
| 45 | + * This is for backward compatibility with pre-RL MediaWiki. |
| 46 | + * |
| 47 | + * @since 0.1 |
| 48 | + */ |
| 49 | + protected static function addJSLocalisation() { |
| 50 | + global $egLTJSMessages, $wgOut; |
| 51 | + |
| 52 | + $data = array(); |
| 53 | + |
| 54 | + foreach ( $egLTJSMessages as $msg ) { |
| 55 | + $data[$msg] = wfMsgNoTrans( $msg ); |
| 56 | + } |
| 57 | + |
| 58 | + $wgOut->addInlineScript( 'var wgLTEMessages = ' . json_encode( $data ) . ';' ); |
| 59 | + } |
| 60 | + |
| 61 | + /** |
| 62 | + * Returns the language code for a title. |
| 63 | + * |
| 64 | + * @param Title $title |
| 65 | + * |
| 66 | + * @return string |
| 67 | + */ |
| 68 | + public static function getCurrentLang( Title $title ) { |
| 69 | + $subPage = array_pop( explode( '/', $title->getSubpageText() ) ); |
| 70 | + |
| 71 | + if ( $subPage != '' && array_key_exists( $subPage, Language::getLanguageNames( false ) ) ) { |
| 72 | + return $subPage; |
| 73 | + } |
| 74 | + |
| 75 | + global $wgLanguageCode; |
| 76 | + return $wgLanguageCode; |
| 77 | + } |
| 78 | + |
| 79 | + /** |
| 80 | + * Returns the HTML for a language selector. |
| 81 | + * |
| 82 | + * @since 0.1 |
| 83 | + * |
| 84 | + * @param string $currentLang |
| 85 | + * |
| 86 | + * @return string |
| 87 | + */ |
| 88 | + public static function getLanguageSelector( $currentLang ) { |
| 89 | + global $wgUser, $wgLanguageCode, $egLiveTranslateLanguages; |
| 90 | + |
| 91 | + $allowedLanguages = array_merge( $egLiveTranslateLanguages, array( $currentLang ) ); |
| 92 | + |
| 93 | + $targetLang = $wgLanguageCode; |
| 94 | + |
| 95 | + $languages = Language::getLanguageNames( false ); |
| 96 | + |
| 97 | + if ( $wgUser->isLoggedIn() ) { |
| 98 | + $userLang = $wgUser->getOption( 'language' ); |
| 99 | + |
| 100 | + if ( array_key_exists( $userLang, $languages ) && in_array( $userLang, $allowedLanguages ) ) { |
| 101 | + $targetLang = $userLang; |
| 102 | + } |
| 103 | + } |
| 104 | + |
| 105 | + $options = array(); |
| 106 | + ksort( $languages ); |
| 107 | + |
| 108 | + foreach ( $languages as $code => $name ) { |
| 109 | + if ( in_array( $code, $allowedLanguages ) && $code != $currentLang ) { |
| 110 | + $display = wfBCP47( $code ) . ' - ' . $name; |
| 111 | + $options[$display] = $code; |
| 112 | + } |
| 113 | + } |
| 114 | + |
| 115 | + $languageSelector = new HTMLSelectField( array( |
| 116 | + 'id' => 'livetranslatelang', |
| 117 | + 'fieldname' => 'language', |
| 118 | + 'options' => $options |
| 119 | + ) ); |
| 120 | + |
| 121 | + return $languageSelector->getInputHTML( $targetLang ); |
| 122 | + } |
| 123 | + |
| 124 | + /** |
| 125 | + * Gets a list of all available languages. |
| 126 | + * |
| 127 | + * @since 0.1 |
| 128 | + * |
| 129 | + * @return array |
| 130 | + */ |
| 131 | + public static function getAvailableLanguages() { |
| 132 | + $dbr = wfGetDB( DB_SLAVE ); |
| 133 | + |
| 134 | + $destinationLangs = array(); |
| 135 | + |
| 136 | + // TODO: fix index |
| 137 | + $res = $dbr->query( 'SELECT DISTINCT word_language FROM ' . $dbr->tableName( 'live_translate' ) ); |
| 138 | + |
| 139 | + while ( $lang = $dbr->fetchObject( $res ) ) { |
| 140 | + $destinationLangs[] = $lang->word_language; |
| 141 | + } |
| 142 | + |
| 143 | + return $destinationLangs; |
| 144 | + } |
| 145 | + |
| 146 | + /** |
| 147 | + * Gets a list of all special words in a language. |
| 148 | + * |
| 149 | + * @since 0.1 |
| 150 | + * |
| 151 | + * @param string $language |
| 152 | + * |
| 153 | + * @return array |
| 154 | + */ |
| 155 | + public static function getSpecialWordsForLang( $language ) { |
| 156 | + $dbr = wfGetDB( DB_SLAVE ); |
| 157 | + |
| 158 | + $words = array(); |
| 159 | + |
| 160 | + // TODO: fix index |
| 161 | + $res = $dbr->query( |
| 162 | + 'SELECT DISTINCT word_translation FROM ' . |
| 163 | + $dbr->tableName( 'live_translate' ) . |
| 164 | + ' WHERE word_language = ' . $dbr->addQuotes( $language ) |
| 165 | + ); |
| 166 | + |
| 167 | + while ( $translation = $dbr->fetchObject( $res ) ) { |
| 168 | + $words[] = $translation->word_translation; |
| 169 | + } |
| 170 | + |
| 171 | + return $words; |
| 172 | + } |
| 173 | + |
| 174 | + /** |
| 175 | + * Returns a PHP version of the JavaScript google.language.Languages enum of the Google Translate v1 API. |
| 176 | + * @see https://code.google.com/apis/language/translate/v1/getting_started.html#LangNameArray |
| 177 | + * |
| 178 | + * @since 0.1 |
| 179 | + * |
| 180 | + * @return array LANGUAGE_NAME => 'code' |
| 181 | + */ |
| 182 | + public static function getGTSupportedLanguages() { //Language::getLanguageNames( false ); |
| 183 | + return array( |
| 184 | + 'AFRIKAANS' => 'af', |
| 185 | + 'ALBANIAN' => 'sq', |
| 186 | + 'AMHARIC' => 'am', |
| 187 | + 'ARABIC' => 'ar', |
| 188 | + 'ARMENIAN' => 'hy', |
| 189 | + 'AZERBAIJANI' => 'az', |
| 190 | + 'BASQUE' => 'eu', |
| 191 | + 'BELARUSIAN' => 'be', |
| 192 | + 'BENGALI' => 'bn', |
| 193 | + 'BIHARI' => 'bh', |
| 194 | + 'BRETON' => 'br', |
| 195 | + 'BULGARIAN' => 'bg', |
| 196 | + 'BURMESE' => 'my', |
| 197 | + 'CATALAN' => 'ca', |
| 198 | + 'CHEROKEE' => 'chr', |
| 199 | + 'CHINESE' => 'zh', |
| 200 | + 'CHINESE_SIMPLIFIED' => 'zh-CN', |
| 201 | + 'CHINESE_TRADITIONAL' => 'zh-TW', |
| 202 | + 'CORSICAN' => 'co', |
| 203 | + 'CROATIAN' => 'hr', |
| 204 | + 'CZECH' => 'cs', |
| 205 | + 'DANISH' => 'da', |
| 206 | + 'DHIVEHI' => 'dv', |
| 207 | + 'DUTCH'=> 'nl', |
| 208 | + 'ENGLISH' => 'en', |
| 209 | + 'ESPERANTO' => 'eo', |
| 210 | + 'ESTONIAN' => 'et', |
| 211 | + 'FAROESE' => 'fo', |
| 212 | + 'FILIPINO' => 'tl', |
| 213 | + 'FINNISH' => 'fi', |
| 214 | + 'FRENCH' => 'fr', |
| 215 | + 'FRISIAN' => 'fy', |
| 216 | + 'GALICIAN' => 'gl', |
| 217 | + 'GEORGIAN' => 'ka', |
| 218 | + 'GERMAN' => 'de', |
| 219 | + 'GREEK' => 'el', |
| 220 | + 'GUJARATI' => 'gu', |
| 221 | + 'HAITIAN_CREOLE' => 'ht', |
| 222 | + 'HEBREW' => 'iw', |
| 223 | + 'HINDI' => 'hi', |
| 224 | + 'HUNGARIAN' => 'hu', |
| 225 | + 'ICELANDIC' => 'is', |
| 226 | + 'INDONESIAN' => 'id', |
| 227 | + 'INUKTITUT' => 'iu', |
| 228 | + 'IRISH' => 'ga', |
| 229 | + 'ITALIAN' => 'it', |
| 230 | + 'JAPANESE' => 'ja', |
| 231 | + 'JAVANESE' => 'jw', |
| 232 | + 'KANNADA' => 'kn', |
| 233 | + 'KAZAKH' => 'kk', |
| 234 | + 'KHMER' => 'km', |
| 235 | + 'KOREAN' => 'ko', |
| 236 | + 'KURDISH'=> 'ku', |
| 237 | + 'KYRGYZ'=> 'ky', |
| 238 | + 'LAO' => 'lo', |
| 239 | + 'LATIN' => 'la', |
| 240 | + 'LATVIAN' => 'lv', |
| 241 | + 'LITHUANIAN' => 'lt', |
| 242 | + 'LUXEMBOURGISH' => 'lb', |
| 243 | + 'MACEDONIAN' => 'mk', |
| 244 | + 'MALAY' => 'ms', |
| 245 | + 'MALAYALAM' => 'ml', |
| 246 | + 'MALTESE' => 'mt', |
| 247 | + 'MAORI' => 'mi', |
| 248 | + 'MARATHI' => 'mr', |
| 249 | + 'MONGOLIAN' => 'mn', |
| 250 | + 'NEPALI' => 'ne', |
| 251 | + 'NORWEGIAN' => 'no', |
| 252 | + 'OCCITAN' => 'oc', |
| 253 | + 'ORIYA' => 'or', |
| 254 | + 'PASHTO' => 'ps', |
| 255 | + 'PERSIAN' => 'fa', |
| 256 | + 'POLISH' => 'pl', |
| 257 | + 'PORTUGUESE' => 'pt', |
| 258 | + 'PORTUGUESE_PORTUGAL' => 'pt-PT', |
| 259 | + 'PUNJABI' => 'pa', |
| 260 | + 'QUECHUA' => 'qu', |
| 261 | + 'ROMANIAN' => 'ro', |
| 262 | + 'RUSSIAN' => 'ru', |
| 263 | + 'SANSKRIT' => 'sa', |
| 264 | + 'SCOTS_GAELIC' => 'gd', |
| 265 | + 'SERBIAN' => 'sr', |
| 266 | + 'SINDHI' => 'sd', |
| 267 | + 'SINHALESE' => 'si', |
| 268 | + 'SLOVAK' => 'sk', |
| 269 | + 'SLOVENIAN' => 'sl', |
| 270 | + 'SPANISH' => 'es', |
| 271 | + 'SUNDANESE' => 'su', |
| 272 | + 'SWAHILI' => 'sw', |
| 273 | + 'SWEDISH' => 'sv', |
| 274 | + 'SYRIAC' => 'syr', |
| 275 | + 'TAJIK' => 'tg', |
| 276 | + 'TAMIL' => 'ta', |
| 277 | + 'TATAR' => 'tt', |
| 278 | + 'TELUGU' => 'te', |
| 279 | + 'THAI' => 'th', |
| 280 | + 'TIBETAN' => 'bo', |
| 281 | + 'TONGA' => 'to', |
| 282 | + 'TURKISH' => 'tr', |
| 283 | + 'UKRAINIAN' => 'uk', |
| 284 | + 'URDU' => 'ur', |
| 285 | + 'UZBEK' => 'uz', |
| 286 | + 'UIGHUR' => 'ug', |
| 287 | + 'VIETNAMESE' => 'vi', |
| 288 | + 'WELSH' => 'cy', |
| 289 | + 'YIDDISH' => 'yi', |
| 290 | + 'YORUBA' => 'yo', |
| 291 | + ); |
| 292 | + } |
| 293 | + |
| 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 | + ); |
| 305 | + } |
| 306 | + |
| 307 | + /** |
| 308 | + * Returns an array with mapping from MediaWiki language codes to Google Translate language codes. |
| 309 | + * |
| 310 | + * @since 0.4 |
| 311 | + * |
| 312 | + * @return array |
| 313 | + */ |
| 314 | + public static function getOuputLangMapping() { |
| 315 | + return array( |
| 316 | + 'en-us' => 'en', |
| 317 | + 'en-gb' => 'en', |
| 318 | + ); |
| 319 | + } |
| 320 | + |
| 321 | + /** |
| 322 | + * Returns the provided text starting with a letter in toggeled case. |
| 323 | + * If there is no difference between lowercase and upercase for the first |
| 324 | + * character, false is returned. |
| 325 | + * |
| 326 | + * @since 0.1 |
| 327 | + * |
| 328 | + * @param string $text |
| 329 | + * |
| 330 | + * @return mixed |
| 331 | + */ |
| 332 | + public static function getToggledCase( $text ) { |
| 333 | + $isUpper = Language::firstChar( $text) == strtoupper( Language::firstChar( $text) ); |
| 334 | + $isLower = Language::firstChar( $text) == strtolower( Language::firstChar( $text) ); |
| 335 | + |
| 336 | + if ( $isUpper XOR $isLower ) { |
| 337 | + $text = $isUpper ? Language::lcfirst( $text ) : Language::ucfirst( $text ); |
| 338 | + return $text; |
| 339 | + } |
| 340 | + else { |
| 341 | + return false; |
| 342 | + } |
| 343 | + } |
| 344 | + |
| 345 | + /** |
| 346 | + * Returns the names of the pages containing a translation memory. |
| 347 | + * |
| 348 | + * @since 0.4 |
| 349 | + * |
| 350 | + * @return array |
| 351 | + */ |
| 352 | + public static function getLocalMemoryNames() { |
| 353 | + $dbr = wfGetDb( DB_MASTER ); |
| 354 | + |
| 355 | + $res = $dbr->select( |
| 356 | + 'live_translate_memories', |
| 357 | + array( 'memory_location' ), |
| 358 | + array( 'memory_local' => 1 ), |
| 359 | + __METHOD__, |
| 360 | + array( 'LIMIT' => '5000' ) |
| 361 | + ); |
| 362 | + |
| 363 | + $names = array(); |
| 364 | + |
| 365 | + foreach ( $res as $tm ) { |
| 366 | + $names[] = $tm->memory_location; |
| 367 | + } |
| 368 | + |
| 369 | + return $names; |
| 370 | + } |
| 371 | + |
| 372 | + /** |
| 373 | + * Returns the type of a translation memory when given it's location. |
| 374 | + * If the memory is not found, -1 is returned. |
| 375 | + * |
| 376 | + * @since 0.4 |
| 377 | + * |
| 378 | + * @param string $location |
| 379 | + * |
| 380 | + * @return integer |
| 381 | + */ |
| 382 | + public static function getMemoryType( $location ) { |
| 383 | + $dbr = wfGetDb( DB_MASTER ); |
| 384 | + |
| 385 | + $res = $dbr->select( |
| 386 | + 'live_translate_memories', |
| 387 | + array( 'memory_type' ), |
| 388 | + array( 'memory_location' => $location ), |
| 389 | + __METHOD__, |
| 390 | + array( 'LIMIT' => '5000' ) |
| 391 | + ); |
| 392 | + |
| 393 | + $type = -1; |
| 394 | + |
| 395 | + foreach ( $res as $row ) { |
| 396 | + $type = $row->memory_type; |
| 397 | + break; |
| 398 | + } |
| 399 | + |
| 400 | + return $type; |
| 401 | + } |
| 402 | + |
| 403 | +} |
\ No newline at end of file |
Property changes on: tags/extensions/LiveTranslate/REL_0_4/includes/LiveTranslate_Functions.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 404 | + native |
Index: tags/extensions/LiveTranslate/REL_0_4/includes/LT_TranslationMemory.php |
— | — | @@ -0,0 +1,76 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * Class describing a translation memory. |
| 6 | + * |
| 7 | + * @since 0.4 |
| 8 | + * |
| 9 | + * @file LT_TranslationMemory.php |
| 10 | + * @ingroup LiveTranslate |
| 11 | + * |
| 12 | + * @licence GNU GPL v3 |
| 13 | + * @author Jeroen De Dauw < jeroendedauw@gmail.com > |
| 14 | + */ |
| 15 | +class LTTranslationMemory { |
| 16 | + |
| 17 | + /** |
| 18 | + * List of translation units in the translation memory. |
| 19 | + * |
| 20 | + * @since 0.4 |
| 21 | + * |
| 22 | + * @var array of LTTMUnit |
| 23 | + */ |
| 24 | + protected $translationUnits = array(); |
| 25 | + |
| 26 | + /** |
| 27 | + * Constructor for a new translation memory object. |
| 28 | + * |
| 29 | + * @since 0.4 |
| 30 | + */ |
| 31 | + public function __construct() { |
| 32 | + |
| 33 | + } |
| 34 | + |
| 35 | + /** |
| 36 | + * Adds a single LTTMUnit to the translation memory. |
| 37 | + * |
| 38 | + * @since 0.4 |
| 39 | + * |
| 40 | + * @param LTTMUnit $tu |
| 41 | + */ |
| 42 | + public function addTranslationUnit( LTTMUnit $tu ) { |
| 43 | + $this->translationUnits[] = $tu; |
| 44 | + } |
| 45 | + |
| 46 | + /** |
| 47 | + * Constructor for a new translation memory object. |
| 48 | + * |
| 49 | + * @since 0.4 |
| 50 | + */ |
| 51 | + public function getTranslationUnits() { |
| 52 | + return $this->translationUnits; |
| 53 | + } |
| 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 | + |
| 77 | +} |
Property changes on: tags/extensions/LiveTranslate/REL_0_4/includes/LT_TranslationMemory.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 78 | + native |
Index: tags/extensions/LiveTranslate/REL_0_4/COPYING |
— | — | @@ -0,0 +1,682 @@ |
| 2 | +The license text below "----" applies to all files within this distribution, other |
| 3 | +than those that are in a directory which contains files named "LICENSE" or |
| 4 | +"COPYING", or a subdirectory thereof. For those files, the license text contained in |
| 5 | +said file overrides any license information contained in directories of smaller depth. |
| 6 | +Alternative licenses are typically used for software that is provided by external |
| 7 | +parties, and merely packaged with this software for convenience. |
| 8 | +---- |
| 9 | + |
| 10 | + GNU GENERAL PUBLIC LICENSE |
| 11 | + Version 3, 29 June 2007 |
| 12 | + |
| 13 | + Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> |
| 14 | + Everyone is permitted to copy and distribute verbatim copies |
| 15 | + of this license document, but changing it is not allowed. |
| 16 | + |
| 17 | + Preamble |
| 18 | + |
| 19 | + The GNU General Public License is a free, copyleft license for |
| 20 | +software and other kinds of works. |
| 21 | + |
| 22 | + The licenses for most software and other practical works are designed |
| 23 | +to take away your freedom to share and change the works. By contrast, |
| 24 | +the GNU General Public License is intended to guarantee your freedom to |
| 25 | +share and change all versions of a program--to make sure it remains free |
| 26 | +software for all its users. We, the Free Software Foundation, use the |
| 27 | +GNU General Public License for most of our software; it applies also to |
| 28 | +any other work released this way by its authors. You can apply it to |
| 29 | +your programs, too. |
| 30 | + |
| 31 | + When we speak of free software, we are referring to freedom, not |
| 32 | +price. Our General Public Licenses are designed to make sure that you |
| 33 | +have the freedom to distribute copies of free software (and charge for |
| 34 | +them if you wish), that you receive source code or can get it if you |
| 35 | +want it, that you can change the software or use pieces of it in new |
| 36 | +free programs, and that you know you can do these things. |
| 37 | + |
| 38 | + To protect your rights, we need to prevent others from denying you |
| 39 | +these rights or asking you to surrender the rights. Therefore, you have |
| 40 | +certain responsibilities if you distribute copies of the software, or if |
| 41 | +you modify it: responsibilities to respect the freedom of others. |
| 42 | + |
| 43 | + For example, if you distribute copies of such a program, whether |
| 44 | +gratis or for a fee, you must pass on to the recipients the same |
| 45 | +freedoms that you received. You must make sure that they, too, receive |
| 46 | +or can get the source code. And you must show them these terms so they |
| 47 | +know their rights. |
| 48 | + |
| 49 | + Developers that use the GNU GPL protect your rights with two steps: |
| 50 | +(1) assert copyright on the software, and (2) offer you this License |
| 51 | +giving you legal permission to copy, distribute and/or modify it. |
| 52 | + |
| 53 | + For the developers' and authors' protection, the GPL clearly explains |
| 54 | +that there is no warranty for this free software. For both users' and |
| 55 | +authors' sake, the GPL requires that modified versions be marked as |
| 56 | +changed, so that their problems will not be attributed erroneously to |
| 57 | +authors of previous versions. |
| 58 | + |
| 59 | + Some devices are designed to deny users access to install or run |
| 60 | +modified versions of the software inside them, although the manufacturer |
| 61 | +can do so. This is fundamentally incompatible with the aim of |
| 62 | +protecting users' freedom to change the software. The systematic |
| 63 | +pattern of such abuse occurs in the area of products for individuals to |
| 64 | +use, which is precisely where it is most unacceptable. Therefore, we |
| 65 | +have designed this version of the GPL to prohibit the practice for those |
| 66 | +products. If such problems arise substantially in other domains, we |
| 67 | +stand ready to extend this provision to those domains in future versions |
| 68 | +of the GPL, as needed to protect the freedom of users. |
| 69 | + |
| 70 | + Finally, every program is threatened constantly by software patents. |
| 71 | +States should not allow patents to restrict development and use of |
| 72 | +software on general-purpose computers, but in those that do, we wish to |
| 73 | +avoid the special danger that patents applied to a free program could |
| 74 | +make it effectively proprietary. To prevent this, the GPL assures that |
| 75 | +patents cannot be used to render the program non-free. |
| 76 | + |
| 77 | + The precise terms and conditions for copying, distribution and |
| 78 | +modification follow. |
| 79 | + |
| 80 | + TERMS AND CONDITIONS |
| 81 | + |
| 82 | + 0. Definitions. |
| 83 | + |
| 84 | + "This License" refers to version 3 of the GNU General Public License. |
| 85 | + |
| 86 | + "Copyright" also means copyright-like laws that apply to other kinds of |
| 87 | +works, such as semiconductor masks. |
| 88 | + |
| 89 | + "The Program" refers to any copyrightable work licensed under this |
| 90 | +License. Each licensee is addressed as "you". "Licensees" and |
| 91 | +"recipients" may be individuals or organizations. |
| 92 | + |
| 93 | + To "modify" a work means to copy from or adapt all or part of the work |
| 94 | +in a fashion requiring copyright permission, other than the making of an |
| 95 | +exact copy. The resulting work is called a "modified version" of the |
| 96 | +earlier work or a work "based on" the earlier work. |
| 97 | + |
| 98 | + A "covered work" means either the unmodified Program or a work based |
| 99 | +on the Program. |
| 100 | + |
| 101 | + To "propagate" a work means to do anything with it that, without |
| 102 | +permission, would make you directly or secondarily liable for |
| 103 | +infringement under applicable copyright law, except executing it on a |
| 104 | +computer or modifying a private copy. Propagation includes copying, |
| 105 | +distribution (with or without modification), making available to the |
| 106 | +public, and in some countries other activities as well. |
| 107 | + |
| 108 | + To "convey" a work means any kind of propagation that enables other |
| 109 | +parties to make or receive copies. Mere interaction with a user through |
| 110 | +a computer network, with no transfer of a copy, is not conveying. |
| 111 | + |
| 112 | + An interactive user interface displays "Appropriate Legal Notices" |
| 113 | +to the extent that it includes a convenient and prominently visible |
| 114 | +feature that (1) displays an appropriate copyright notice, and (2) |
| 115 | +tells the user that there is no warranty for the work (except to the |
| 116 | +extent that warranties are provided), that licensees may convey the |
| 117 | +work under this License, and how to view a copy of this License. If |
| 118 | +the interface presents a list of user commands or options, such as a |
| 119 | +menu, a prominent item in the list meets this criterion. |
| 120 | + |
| 121 | + 1. Source Code. |
| 122 | + |
| 123 | + The "source code" for a work means the preferred form of the work |
| 124 | +for making modifications to it. "Object code" means any non-source |
| 125 | +form of a work. |
| 126 | + |
| 127 | + A "Standard Interface" means an interface that either is an official |
| 128 | +standard defined by a recognized standards body, or, in the case of |
| 129 | +interfaces specified for a particular programming language, one that |
| 130 | +is widely used among developers working in that language. |
| 131 | + |
| 132 | + The "System Libraries" of an executable work include anything, other |
| 133 | +than the work as a whole, that (a) is included in the normal form of |
| 134 | +packaging a Major Component, but which is not part of that Major |
| 135 | +Component, and (b) serves only to enable use of the work with that |
| 136 | +Major Component, or to implement a Standard Interface for which an |
| 137 | +implementation is available to the public in source code form. A |
| 138 | +"Major Component", in this context, means a major essential component |
| 139 | +(kernel, window system, and so on) of the specific operating system |
| 140 | +(if any) on which the executable work runs, or a compiler used to |
| 141 | +produce the work, or an object code interpreter used to run it. |
| 142 | + |
| 143 | + The "Corresponding Source" for a work in object code form means all |
| 144 | +the source code needed to generate, install, and (for an executable |
| 145 | +work) run the object code and to modify the work, including scripts to |
| 146 | +control those activities. However, it does not include the work's |
| 147 | +System Libraries, or general-purpose tools or generally available free |
| 148 | +programs which are used unmodified in performing those activities but |
| 149 | +which are not part of the work. For example, Corresponding Source |
| 150 | +includes interface definition files associated with source files for |
| 151 | +the work, and the source code for shared libraries and dynamically |
| 152 | +linked subprograms that the work is specifically designed to require, |
| 153 | +such as by intimate data communication or control flow between those |
| 154 | +subprograms and other parts of the work. |
| 155 | + |
| 156 | + The Corresponding Source need not include anything that users |
| 157 | +can regenerate automatically from other parts of the Corresponding |
| 158 | +Source. |
| 159 | + |
| 160 | + The Corresponding Source for a work in source code form is that |
| 161 | +same work. |
| 162 | + |
| 163 | + 2. Basic Permissions. |
| 164 | + |
| 165 | + All rights granted under this License are granted for the term of |
| 166 | +copyright on the Program, and are irrevocable provided the stated |
| 167 | +conditions are met. This License explicitly affirms your unlimited |
| 168 | +permission to run the unmodified Program. The output from running a |
| 169 | +covered work is covered by this License only if the output, given its |
| 170 | +content, constitutes a covered work. This License acknowledges your |
| 171 | +rights of fair use or other equivalent, as provided by copyright law. |
| 172 | + |
| 173 | + You may make, run and propagate covered works that you do not |
| 174 | +convey, without conditions so long as your license otherwise remains |
| 175 | +in force. You may convey covered works to others for the sole purpose |
| 176 | +of having them make modifications exclusively for you, or provide you |
| 177 | +with facilities for running those works, provided that you comply with |
| 178 | +the terms of this License in conveying all material for which you do |
| 179 | +not control copyright. Those thus making or running the covered works |
| 180 | +for you must do so exclusively on your behalf, under your direction |
| 181 | +and control, on terms that prohibit them from making any copies of |
| 182 | +your copyrighted material outside their relationship with you. |
| 183 | + |
| 184 | + Conveying under any other circumstances is permitted solely under |
| 185 | +the conditions stated below. Sublicensing is not allowed; section 10 |
| 186 | +makes it unnecessary. |
| 187 | + |
| 188 | + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. |
| 189 | + |
| 190 | + No covered work shall be deemed part of an effective technological |
| 191 | +measure under any applicable law fulfilling obligations under article |
| 192 | +11 of the WIPO copyright treaty adopted on 20 December 1996, or |
| 193 | +similar laws prohibiting or restricting circumvention of such |
| 194 | +measures. |
| 195 | + |
| 196 | + When you convey a covered work, you waive any legal power to forbid |
| 197 | +circumvention of technological measures to the extent such circumvention |
| 198 | +is effected by exercising rights under this License with respect to |
| 199 | +the covered work, and you disclaim any intention to limit operation or |
| 200 | +modification of the work as a means of enforcing, against the work's |
| 201 | +users, your or third parties' legal rights to forbid circumvention of |
| 202 | +technological measures. |
| 203 | + |
| 204 | + 4. Conveying Verbatim Copies. |
| 205 | + |
| 206 | + You may convey verbatim copies of the Program's source code as you |
| 207 | +receive it, in any medium, provided that you conspicuously and |
| 208 | +appropriately publish on each copy an appropriate copyright notice; |
| 209 | +keep intact all notices stating that this License and any |
| 210 | +non-permissive terms added in accord with section 7 apply to the code; |
| 211 | +keep intact all notices of the absence of any warranty; and give all |
| 212 | +recipients a copy of this License along with the Program. |
| 213 | + |
| 214 | + You may charge any price or no price for each copy that you convey, |
| 215 | +and you may offer support or warranty protection for a fee. |
| 216 | + |
| 217 | + 5. Conveying Modified Source Versions. |
| 218 | + |
| 219 | + You may convey a work based on the Program, or the modifications to |
| 220 | +produce it from the Program, in the form of source code under the |
| 221 | +terms of section 4, provided that you also meet all of these conditions: |
| 222 | + |
| 223 | + a) The work must carry prominent notices stating that you modified |
| 224 | + it, and giving a relevant date. |
| 225 | + |
| 226 | + b) The work must carry prominent notices stating that it is |
| 227 | + released under this License and any conditions added under section |
| 228 | + 7. This requirement modifies the requirement in section 4 to |
| 229 | + "keep intact all notices". |
| 230 | + |
| 231 | + c) You must license the entire work, as a whole, under this |
| 232 | + License to anyone who comes into possession of a copy. This |
| 233 | + License will therefore apply, along with any applicable section 7 |
| 234 | + additional terms, to the whole of the work, and all its parts, |
| 235 | + regardless of how they are packaged. This License gives no |
| 236 | + permission to license the work in any other way, but it does not |
| 237 | + invalidate such permission if you have separately received it. |
| 238 | + |
| 239 | + d) If the work has interactive user interfaces, each must display |
| 240 | + Appropriate Legal Notices; however, if the Program has interactive |
| 241 | + interfaces that do not display Appropriate Legal Notices, your |
| 242 | + work need not make them do so. |
| 243 | + |
| 244 | + A compilation of a covered work with other separate and independent |
| 245 | +works, which are not by their nature extensions of the covered work, |
| 246 | +and which are not combined with it such as to form a larger program, |
| 247 | +in or on a volume of a storage or distribution medium, is called an |
| 248 | +"aggregate" if the compilation and its resulting copyright are not |
| 249 | +used to limit the access or legal rights of the compilation's users |
| 250 | +beyond what the individual works permit. Inclusion of a covered work |
| 251 | +in an aggregate does not cause this License to apply to the other |
| 252 | +parts of the aggregate. |
| 253 | + |
| 254 | + 6. Conveying Non-Source Forms. |
| 255 | + |
| 256 | + You may convey a covered work in object code form under the terms |
| 257 | +of sections 4 and 5, provided that you also convey the |
| 258 | +machine-readable Corresponding Source under the terms of this License, |
| 259 | +in one of these ways: |
| 260 | + |
| 261 | + a) Convey the object code in, or embodied in, a physical product |
| 262 | + (including a physical distribution medium), accompanied by the |
| 263 | + Corresponding Source fixed on a durable physical medium |
| 264 | + customarily used for software interchange. |
| 265 | + |
| 266 | + b) Convey the object code in, or embodied in, a physical product |
| 267 | + (including a physical distribution medium), accompanied by a |
| 268 | + written offer, valid for at least three years and valid for as |
| 269 | + long as you offer spare parts or customer support for that product |
| 270 | + model, to give anyone who possesses the object code either (1) a |
| 271 | + copy of the Corresponding Source for all the software in the |
| 272 | + product that is covered by this License, on a durable physical |
| 273 | + medium customarily used for software interchange, for a price no |
| 274 | + more than your reasonable cost of physically performing this |
| 275 | + conveying of source, or (2) access to copy the |
| 276 | + Corresponding Source from a network server at no charge. |
| 277 | + |
| 278 | + c) Convey individual copies of the object code with a copy of the |
| 279 | + written offer to provide the Corresponding Source. This |
| 280 | + alternative is allowed only occasionally and noncommercially, and |
| 281 | + only if you received the object code with such an offer, in accord |
| 282 | + with subsection 6b. |
| 283 | + |
| 284 | + d) Convey the object code by offering access from a designated |
| 285 | + place (gratis or for a charge), and offer equivalent access to the |
| 286 | + Corresponding Source in the same way through the same place at no |
| 287 | + further charge. You need not require recipients to copy the |
| 288 | + Corresponding Source along with the object code. If the place to |
| 289 | + copy the object code is a network server, the Corresponding Source |
| 290 | + may be on a different server (operated by you or a third party) |
| 291 | + that supports equivalent copying facilities, provided you maintain |
| 292 | + clear directions next to the object code saying where to find the |
| 293 | + Corresponding Source. Regardless of what server hosts the |
| 294 | + Corresponding Source, you remain obligated to ensure that it is |
| 295 | + available for as long as needed to satisfy these requirements. |
| 296 | + |
| 297 | + e) Convey the object code using peer-to-peer transmission, provided |
| 298 | + you inform other peers where the object code and Corresponding |
| 299 | + Source of the work are being offered to the general public at no |
| 300 | + charge under subsection 6d. |
| 301 | + |
| 302 | + A separable portion of the object code, whose source code is excluded |
| 303 | +from the Corresponding Source as a System Library, need not be |
| 304 | +included in conveying the object code work. |
| 305 | + |
| 306 | + A "User Product" is either (1) a "consumer product", which means any |
| 307 | +tangible personal property which is normally used for personal, family, |
| 308 | +or household purposes, or (2) anything designed or sold for incorporation |
| 309 | +into a dwelling. In determining whether a product is a consumer product, |
| 310 | +doubtful cases shall be resolved in favor of coverage. For a particular |
| 311 | +product received by a particular user, "normally used" refers to a |
| 312 | +typical or common use of that class of product, regardless of the status |
| 313 | +of the particular user or of the way in which the particular user |
| 314 | +actually uses, or expects or is expected to use, the product. A product |
| 315 | +is a consumer product regardless of whether the product has substantial |
| 316 | +commercial, industrial or non-consumer uses, unless such uses represent |
| 317 | +the only significant mode of use of the product. |
| 318 | + |
| 319 | + "Installation Information" for a User Product means any methods, |
| 320 | +procedures, authorization keys, or other information required to install |
| 321 | +and execute modified versions of a covered work in that User Product from |
| 322 | +a modified version of its Corresponding Source. The information must |
| 323 | +suffice to ensure that the continued functioning of the modified object |
| 324 | +code is in no case prevented or interfered with solely because |
| 325 | +modification has been made. |
| 326 | + |
| 327 | + If you convey an object code work under this section in, or with, or |
| 328 | +specifically for use in, a User Product, and the conveying occurs as |
| 329 | +part of a transaction in which the right of possession and use of the |
| 330 | +User Product is transferred to the recipient in perpetuity or for a |
| 331 | +fixed term (regardless of how the transaction is characterized), the |
| 332 | +Corresponding Source conveyed under this section must be accompanied |
| 333 | +by the Installation Information. But this requirement does not apply |
| 334 | +if neither you nor any third party retains the ability to install |
| 335 | +modified object code on the User Product (for example, the work has |
| 336 | +been installed in ROM). |
| 337 | + |
| 338 | + The requirement to provide Installation Information does not include a |
| 339 | +requirement to continue to provide support service, warranty, or updates |
| 340 | +for a work that has been modified or installed by the recipient, or for |
| 341 | +the User Product in which it has been modified or installed. Access to a |
| 342 | +network may be denied when the modification itself materially and |
| 343 | +adversely affects the operation of the network or violates the rules and |
| 344 | +protocols for communication across the network. |
| 345 | + |
| 346 | + Corresponding Source conveyed, and Installation Information provided, |
| 347 | +in accord with this section must be in a format that is publicly |
| 348 | +documented (and with an implementation available to the public in |
| 349 | +source code form), and must require no special password or key for |
| 350 | +unpacking, reading or copying. |
| 351 | + |
| 352 | + 7. Additional Terms. |
| 353 | + |
| 354 | + "Additional permissions" are terms that supplement the terms of this |
| 355 | +License by making exceptions from one or more of its conditions. |
| 356 | +Additional permissions that are applicable to the entire Program shall |
| 357 | +be treated as though they were included in this License, to the extent |
| 358 | +that they are valid under applicable law. If additional permissions |
| 359 | +apply only to part of the Program, that part may be used separately |
| 360 | +under those permissions, but the entire Program remains governed by |
| 361 | +this License without regard to the additional permissions. |
| 362 | + |
| 363 | + When you convey a copy of a covered work, you may at your option |
| 364 | +remove any additional permissions from that copy, or from any part of |
| 365 | +it. (Additional permissions may be written to require their own |
| 366 | +removal in certain cases when you modify the work.) You may place |
| 367 | +additional permissions on material, added by you to a covered work, |
| 368 | +for which you have or can give appropriate copyright permission. |
| 369 | + |
| 370 | + Notwithstanding any other provision of this License, for material you |
| 371 | +add to a covered work, you may (if authorized by the copyright holders of |
| 372 | +that material) supplement the terms of this License with terms: |
| 373 | + |
| 374 | + a) Disclaiming warranty or limiting liability differently from the |
| 375 | + terms of sections 15 and 16 of this License; or |
| 376 | + |
| 377 | + b) Requiring preservation of specified reasonable legal notices or |
| 378 | + author attributions in that material or in the Appropriate Legal |
| 379 | + Notices displayed by works containing it; or |
| 380 | + |
| 381 | + c) Prohibiting misrepresentation of the origin of that material, or |
| 382 | + requiring that modified versions of such material be marked in |
| 383 | + reasonable ways as different from the original version; or |
| 384 | + |
| 385 | + d) Limiting the use for publicity purposes of names of licensors or |
| 386 | + authors of the material; or |
| 387 | + |
| 388 | + e) Declining to grant rights under trademark law for use of some |
| 389 | + trade names, trademarks, or service marks; or |
| 390 | + |
| 391 | + f) Requiring indemnification of licensors and authors of that |
| 392 | + material by anyone who conveys the material (or modified versions of |
| 393 | + it) with contractual assumptions of liability to the recipient, for |
| 394 | + any liability that these contractual assumptions directly impose on |
| 395 | + those licensors and authors. |
| 396 | + |
| 397 | + All other non-permissive additional terms are considered "further |
| 398 | +restrictions" within the meaning of section 10. If the Program as you |
| 399 | +received it, or any part of it, contains a notice stating that it is |
| 400 | +governed by this License along with a term that is a further |
| 401 | +restriction, you may remove that term. If a license document contains |
| 402 | +a further restriction but permits relicensing or conveying under this |
| 403 | +License, you may add to a covered work material governed by the terms |
| 404 | +of that license document, provided that the further restriction does |
| 405 | +not survive such relicensing or conveying. |
| 406 | + |
| 407 | + If you add terms to a covered work in accord with this section, you |
| 408 | +must place, in the relevant source files, a statement of the |
| 409 | +additional terms that apply to those files, or a notice indicating |
| 410 | +where to find the applicable terms. |
| 411 | + |
| 412 | + Additional terms, permissive or non-permissive, may be stated in the |
| 413 | +form of a separately written license, or stated as exceptions; |
| 414 | +the above requirements apply either way. |
| 415 | + |
| 416 | + 8. Termination. |
| 417 | + |
| 418 | + You may not propagate or modify a covered work except as expressly |
| 419 | +provided under this License. Any attempt otherwise to propagate or |
| 420 | +modify it is void, and will automatically terminate your rights under |
| 421 | +this License (including any patent licenses granted under the third |
| 422 | +paragraph of section 11). |
| 423 | + |
| 424 | + However, if you cease all violation of this License, then your |
| 425 | +license from a particular copyright holder is reinstated (a) |
| 426 | +provisionally, unless and until the copyright holder explicitly and |
| 427 | +finally terminates your license, and (b) permanently, if the copyright |
| 428 | +holder fails to notify you of the violation by some reasonable means |
| 429 | +prior to 60 days after the cessation. |
| 430 | + |
| 431 | + Moreover, your license from a particular copyright holder is |
| 432 | +reinstated permanently if the copyright holder notifies you of the |
| 433 | +violation by some reasonable means, this is the first time you have |
| 434 | +received notice of violation of this License (for any work) from that |
| 435 | +copyright holder, and you cure the violation prior to 30 days after |
| 436 | +your receipt of the notice. |
| 437 | + |
| 438 | + Termination of your rights under this section does not terminate the |
| 439 | +licenses of parties who have received copies or rights from you under |
| 440 | +this License. If your rights have been terminated and not permanently |
| 441 | +reinstated, you do not qualify to receive new licenses for the same |
| 442 | +material under section 10. |
| 443 | + |
| 444 | + 9. Acceptance Not Required for Having Copies. |
| 445 | + |
| 446 | + You are not required to accept this License in order to receive or |
| 447 | +run a copy of the Program. Ancillary propagation of a covered work |
| 448 | +occurring solely as a consequence of using peer-to-peer transmission |
| 449 | +to receive a copy likewise does not require acceptance. However, |
| 450 | +nothing other than this License grants you permission to propagate or |
| 451 | +modify any covered work. These actions infringe copyright if you do |
| 452 | +not accept this License. Therefore, by modifying or propagating a |
| 453 | +covered work, you indicate your acceptance of this License to do so. |
| 454 | + |
| 455 | + 10. Automatic Licensing of Downstream Recipients. |
| 456 | + |
| 457 | + Each time you convey a covered work, the recipient automatically |
| 458 | +receives a license from the original licensors, to run, modify and |
| 459 | +propagate that work, subject to this License. You are not responsible |
| 460 | +for enforcing compliance by third parties with this License. |
| 461 | + |
| 462 | + An "entity transaction" is a transaction transferring control of an |
| 463 | +organization, or substantially all assets of one, or subdividing an |
| 464 | +organization, or merging organizations. If propagation of a covered |
| 465 | +work results from an entity transaction, each party to that |
| 466 | +transaction who receives a copy of the work also receives whatever |
| 467 | +licenses to the work the party's predecessor in interest had or could |
| 468 | +give under the previous paragraph, plus a right to possession of the |
| 469 | +Corresponding Source of the work from the predecessor in interest, if |
| 470 | +the predecessor has it or can get it with reasonable efforts. |
| 471 | + |
| 472 | + You may not impose any further restrictions on the exercise of the |
| 473 | +rights granted or affirmed under this License. For example, you may |
| 474 | +not impose a license fee, royalty, or other charge for exercise of |
| 475 | +rights granted under this License, and you may not initiate litigation |
| 476 | +(including a cross-claim or counterclaim in a lawsuit) alleging that |
| 477 | +any patent claim is infringed by making, using, selling, offering for |
| 478 | +sale, or importing the Program or any portion of it. |
| 479 | + |
| 480 | + 11. Patents. |
| 481 | + |
| 482 | + A "contributor" is a copyright holder who authorizes use under this |
| 483 | +License of the Program or a work on which the Program is based. The |
| 484 | +work thus licensed is called the contributor's "contributor version". |
| 485 | + |
| 486 | + A contributor's "essential patent claims" are all patent claims |
| 487 | +owned or controlled by the contributor, whether already acquired or |
| 488 | +hereafter acquired, that would be infringed by some manner, permitted |
| 489 | +by this License, of making, using, or selling its contributor version, |
| 490 | +but do not include claims that would be infringed only as a |
| 491 | +consequence of further modification of the contributor version. For |
| 492 | +purposes of this definition, "control" includes the right to grant |
| 493 | +patent sublicenses in a manner consistent with the requirements of |
| 494 | +this License. |
| 495 | + |
| 496 | + Each contributor grants you a non-exclusive, worldwide, royalty-free |
| 497 | +patent license under the contributor's essential patent claims, to |
| 498 | +make, use, sell, offer for sale, import and otherwise run, modify and |
| 499 | +propagate the contents of its contributor version. |
| 500 | + |
| 501 | + In the following three paragraphs, a "patent license" is any express |
| 502 | +agreement or commitment, however denominated, not to enforce a patent |
| 503 | +(such as an express permission to practice a patent or covenant not to |
| 504 | +sue for patent infringement). To "grant" such a patent license to a |
| 505 | +party means to make such an agreement or commitment not to enforce a |
| 506 | +patent against the party. |
| 507 | + |
| 508 | + If you convey a covered work, knowingly relying on a patent license, |
| 509 | +and the Corresponding Source of the work is not available for anyone |
| 510 | +to copy, free of charge and under the terms of this License, through a |
| 511 | +publicly available network server or other readily accessible means, |
| 512 | +then you must either (1) cause the Corresponding Source to be so |
| 513 | +available, or (2) arrange to deprive yourself of the benefit of the |
| 514 | +patent license for this particular work, or (3) arrange, in a manner |
| 515 | +consistent with the requirements of this License, to extend the patent |
| 516 | +license to downstream recipients. "Knowingly relying" means you have |
| 517 | +actual knowledge that, but for the patent license, your conveying the |
| 518 | +covered work in a country, or your recipient's use of the covered work |
| 519 | +in a country, would infringe one or more identifiable patents in that |
| 520 | +country that you have reason to believe are valid. |
| 521 | + |
| 522 | + If, pursuant to or in connection with a single transaction or |
| 523 | +arrangement, you convey, or propagate by procuring conveyance of, a |
| 524 | +covered work, and grant a patent license to some of the parties |
| 525 | +receiving the covered work authorizing them to use, propagate, modify |
| 526 | +or convey a specific copy of the covered work, then the patent license |
| 527 | +you grant is automatically extended to all recipients of the covered |
| 528 | +work and works based on it. |
| 529 | + |
| 530 | + A patent license is "discriminatory" if it does not include within |
| 531 | +the scope of its coverage, prohibits the exercise of, or is |
| 532 | +conditioned on the non-exercise of one or more of the rights that are |
| 533 | +specifically granted under this License. You may not convey a covered |
| 534 | +work if you are a party to an arrangement with a third party that is |
| 535 | +in the business of distributing software, under which you make payment |
| 536 | +to the third party based on the extent of your activity of conveying |
| 537 | +the work, and under which the third party grants, to any of the |
| 538 | +parties who would receive the covered work from you, a discriminatory |
| 539 | +patent license (a) in connection with copies of the covered work |
| 540 | +conveyed by you (or copies made from those copies), or (b) primarily |
| 541 | +for and in connection with specific products or compilations that |
| 542 | +contain the covered work, unless you entered into that arrangement, |
| 543 | +or that patent license was granted, prior to 28 March 2007. |
| 544 | + |
| 545 | + Nothing in this License shall be construed as excluding or limiting |
| 546 | +any implied license or other defenses to infringement that may |
| 547 | +otherwise be available to you under applicable patent law. |
| 548 | + |
| 549 | + 12. No Surrender of Others' Freedom. |
| 550 | + |
| 551 | + If conditions are imposed on you (whether by court order, agreement or |
| 552 | +otherwise) that contradict the conditions of this License, they do not |
| 553 | +excuse you from the conditions of this License. If you cannot convey a |
| 554 | +covered work so as to satisfy simultaneously your obligations under this |
| 555 | +License and any other pertinent obligations, then as a consequence you may |
| 556 | +not convey it at all. For example, if you agree to terms that obligate you |
| 557 | +to collect a royalty for further conveying from those to whom you convey |
| 558 | +the Program, the only way you could satisfy both those terms and this |
| 559 | +License would be to refrain entirely from conveying the Program. |
| 560 | + |
| 561 | + 13. Use with the GNU Affero General Public License. |
| 562 | + |
| 563 | + Notwithstanding any other provision of this License, you have |
| 564 | +permission to link or combine any covered work with a work licensed |
| 565 | +under version 3 of the GNU Affero General Public License into a single |
| 566 | +combined work, and to convey the resulting work. The terms of this |
| 567 | +License will continue to apply to the part which is the covered work, |
| 568 | +but the special requirements of the GNU Affero General Public License, |
| 569 | +section 13, concerning interaction through a network will apply to the |
| 570 | +combination as such. |
| 571 | + |
| 572 | + 14. Revised Versions of this License. |
| 573 | + |
| 574 | + The Free Software Foundation may publish revised and/or new versions of |
| 575 | +the GNU General Public License from time to time. Such new versions will |
| 576 | +be similar in spirit to the present version, but may differ in detail to |
| 577 | +address new problems or concerns. |
| 578 | + |
| 579 | + Each version is given a distinguishing version number. If the |
| 580 | +Program specifies that a certain numbered version of the GNU General |
| 581 | +Public License "or any later version" applies to it, you have the |
| 582 | +option of following the terms and conditions either of that numbered |
| 583 | +version or of any later version published by the Free Software |
| 584 | +Foundation. If the Program does not specify a version number of the |
| 585 | +GNU General Public License, you may choose any version ever published |
| 586 | +by the Free Software Foundation. |
| 587 | + |
| 588 | + If the Program specifies that a proxy can decide which future |
| 589 | +versions of the GNU General Public License can be used, that proxy's |
| 590 | +public statement of acceptance of a version permanently authorizes you |
| 591 | +to choose that version for the Program. |
| 592 | + |
| 593 | + Later license versions may give you additional or different |
| 594 | +permissions. However, no additional obligations are imposed on any |
| 595 | +author or copyright holder as a result of your choosing to follow a |
| 596 | +later version. |
| 597 | + |
| 598 | + 15. Disclaimer of Warranty. |
| 599 | + |
| 600 | + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY |
| 601 | +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT |
| 602 | +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY |
| 603 | +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, |
| 604 | +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 605 | +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM |
| 606 | +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF |
| 607 | +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. |
| 608 | + |
| 609 | + 16. Limitation of Liability. |
| 610 | + |
| 611 | + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING |
| 612 | +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS |
| 613 | +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY |
| 614 | +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE |
| 615 | +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF |
| 616 | +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD |
| 617 | +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), |
| 618 | +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF |
| 619 | +SUCH DAMAGES. |
| 620 | + |
| 621 | + 17. Interpretation of Sections 15 and 16. |
| 622 | + |
| 623 | + If the disclaimer of warranty and limitation of liability provided |
| 624 | +above cannot be given local legal effect according to their terms, |
| 625 | +reviewing courts shall apply local law that most closely approximates |
| 626 | +an absolute waiver of all civil liability in connection with the |
| 627 | +Program, unless a warranty or assumption of liability accompanies a |
| 628 | +copy of the Program in return for a fee. |
| 629 | + |
| 630 | + END OF TERMS AND CONDITIONS |
| 631 | + |
| 632 | + How to Apply These Terms to Your New Programs |
| 633 | + |
| 634 | + If you develop a new program, and you want it to be of the greatest |
| 635 | +possible use to the public, the best way to achieve this is to make it |
| 636 | +free software which everyone can redistribute and change under these terms. |
| 637 | + |
| 638 | + To do so, attach the following notices to the program. It is safest |
| 639 | +to attach them to the start of each source file to most effectively |
| 640 | +state the exclusion of warranty; and each file should have at least |
| 641 | +the "copyright" line and a pointer to where the full notice is found. |
| 642 | + |
| 643 | + <one line to give the program's name and a brief idea of what it does.> |
| 644 | + Copyright (C) <year> <name of author> |
| 645 | + |
| 646 | + This program is free software: you can redistribute it and/or modify |
| 647 | + it under the terms of the GNU General Public License as published by |
| 648 | + the Free Software Foundation, either version 3 of the License, or |
| 649 | + (at your option) any later version. |
| 650 | + |
| 651 | + This program is distributed in the hope that it will be useful, |
| 652 | + but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 653 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 654 | + GNU General Public License for more details. |
| 655 | + |
| 656 | + You should have received a copy of the GNU General Public License |
| 657 | + along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 658 | + |
| 659 | +Also add information on how to contact you by electronic and paper mail. |
| 660 | + |
| 661 | + If the program does terminal interaction, make it output a short |
| 662 | +notice like this when it starts in an interactive mode: |
| 663 | + |
| 664 | + <program> Copyright (C) <year> <name of author> |
| 665 | + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. |
| 666 | + This is free software, and you are welcome to redistribute it |
| 667 | + under certain conditions; type `show c' for details. |
| 668 | + |
| 669 | +The hypothetical commands `show w' and `show c' should show the appropriate |
| 670 | +parts of the General Public License. Of course, your program's commands |
| 671 | +might be different; for a GUI interface, you would use an "about box". |
| 672 | + |
| 673 | + You should also get your employer (if you work as a programmer) or school, |
| 674 | +if any, to sign a "copyright disclaimer" for the program, if necessary. |
| 675 | +For more information on this, and how to apply and follow the GNU GPL, see |
| 676 | +<http://www.gnu.org/licenses/>. |
| 677 | + |
| 678 | + The GNU General Public License does not permit incorporating your program |
| 679 | +into proprietary programs. If your program is a subroutine library, you |
| 680 | +may consider it more useful to permit linking proprietary applications with |
| 681 | +the library. If this is what you want to do, use the GNU Lesser General |
| 682 | +Public License instead of this License. But first, please read |
| 683 | +<http://www.gnu.org/philosophy/why-not-lgpl.html>. |
\ No newline at end of file |
Index: tags/extensions/LiveTranslate/REL_0_4/api/ApiQueryLiveTranslate.php |
— | — | @@ -0,0 +1,105 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * API module to get special words for a language stored by the Live Translate extension. |
| 6 | + * |
| 7 | + * @since 0.2 |
| 8 | + * |
| 9 | + * @file ApiQueryLiveTranslate.php |
| 10 | + * @ingroup LiveTranslate |
| 11 | + * |
| 12 | + * @author Jeroen De Dauw < jeroendedauw@gmail.com > |
| 13 | + */ |
| 14 | +class ApiQueryLiveTranslate extends ApiQueryBase { |
| 15 | + public function __construct( $main, $action ) { |
| 16 | + parent :: __construct( $main, $action, 'lt' ); |
| 17 | + } |
| 18 | + |
| 19 | + /** |
| 20 | + * Retrieve the specil words from the database. |
| 21 | + */ |
| 22 | + public function execute() { |
| 23 | + // Get the requests parameters. |
| 24 | + $params = $this->extractRequestParams(); |
| 25 | + |
| 26 | + if ( !isset( $params['language'] ) ) { |
| 27 | + $this->dieUsageMsg( array( 'missingparam', 'language' ) ); |
| 28 | + } |
| 29 | + |
| 30 | + $specialWords = LiveTranslateFunctions::getSpecialWordsForLang( $params['language'] ); |
| 31 | + |
| 32 | + $toggeledSpecials = array(); |
| 33 | + |
| 34 | + foreach ( $specialWords as $word ) { |
| 35 | + $toggledWord = LiveTranslateFunctions::getToggledCase( $word ); |
| 36 | + |
| 37 | + if ( $toggledWord ) { |
| 38 | + $toggeledSpecials[] = $toggledWord; |
| 39 | + } |
| 40 | + } |
| 41 | + |
| 42 | + foreach ( array_unique( array_merge( $specialWords, $toggeledSpecials ) ) as $word ) { |
| 43 | + $this->getResult()->addValue( |
| 44 | + 'words', |
| 45 | + null, |
| 46 | + $word |
| 47 | + ); |
| 48 | + } |
| 49 | + } |
| 50 | + |
| 51 | + /** |
| 52 | + * (non-PHPdoc) |
| 53 | + * @see includes/api/ApiBase#getAllowedParams() |
| 54 | + */ |
| 55 | + public function getAllowedParams() { |
| 56 | + return array ( |
| 57 | + 'language' => array( |
| 58 | + ApiBase::PARAM_TYPE => 'string', |
| 59 | + //ApiBase::PARAM_REQUIRED => true, |
| 60 | + ), |
| 61 | + ); |
| 62 | + } |
| 63 | + |
| 64 | + /** |
| 65 | + * (non-PHPdoc) |
| 66 | + * @see includes/api/ApiBase#getParamDescription() |
| 67 | + */ |
| 68 | + public function getParamDescription() { |
| 69 | + return array ( |
| 70 | + 'language' => 'The language for which to return special words', |
| 71 | + ); |
| 72 | + } |
| 73 | + |
| 74 | + /** |
| 75 | + * (non-PHPdoc) |
| 76 | + * @see includes/api/ApiBase#getDescription() |
| 77 | + */ |
| 78 | + public function getDescription() { |
| 79 | + return 'This module returns all special words defined in the wikis Live Translate Dictionary for a given language'; |
| 80 | + } |
| 81 | + |
| 82 | + /** |
| 83 | + * (non-PHPdoc) |
| 84 | + * @see includes/api/ApiBase#getPossibleErrors() |
| 85 | + */ |
| 86 | + public function getPossibleErrors() { |
| 87 | + return array_merge( parent::getPossibleErrors(), array( |
| 88 | + array( 'missingparam', 'language' ), |
| 89 | + ) ); |
| 90 | + } |
| 91 | + |
| 92 | + /** |
| 93 | + * (non-PHPdoc) |
| 94 | + * @see includes/api/ApiBase#getExamples() |
| 95 | + */ |
| 96 | + protected function getExamples() { |
| 97 | + return array ( |
| 98 | + 'api.php?action=query&list=livetranslate<language', |
| 99 | + ); |
| 100 | + } |
| 101 | + |
| 102 | + public function getVersion() { |
| 103 | + return __CLASS__ . ': $Id: ApiQueryLiveTranslate.php 78939 2010-12-24 00:21:45Z jeroendedauw $'; |
| 104 | + } |
| 105 | + |
| 106 | +} |
Property changes on: tags/extensions/LiveTranslate/REL_0_4/api/ApiQueryLiveTranslate.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 107 | + native |
Index: tags/extensions/LiveTranslate/REL_0_4/api/ApiImportTranslationMemories.php |
— | — | @@ -0,0 +1,197 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * API module to get special translations stored by the Live Translate extension. |
| 6 | + * |
| 7 | + * @since 0.4 |
| 8 | + * |
| 9 | + * @file ApiImportTranslationMemories.php |
| 10 | + * @ingroup LiveTranslate |
| 11 | + * |
| 12 | + * @licence GNU GPL v3 or later |
| 13 | + * @author Jeroen De Dauw < jeroendedauw@gmail.com > |
| 14 | + */ |
| 15 | +class ApiImportTranslationMemories extends ApiBase { |
| 16 | + |
| 17 | + public function __construct( $main, $action ) { |
| 18 | + parent::__construct( $main, $action ); |
| 19 | + } |
| 20 | + |
| 21 | + public function execute() { |
| 22 | + global $wgUser; |
| 23 | + |
| 24 | + $params = $this->extractRequestParams(); |
| 25 | + |
| 26 | + // In MW 1.17 and above ApiBase::PARAM_REQUIRED can be used, this is for b/c with 1.16. |
| 27 | + foreach ( array( 'source' ) as $requiredParam ) { |
| 28 | + if ( !isset( $params[$requiredParam] ) ) { |
| 29 | + $this->dieUsageMsg( array( 'missingparam', $requiredParam ) ); |
| 30 | + } |
| 31 | + } |
| 32 | + |
| 33 | + foreach ( $params['source'] as $location ) { |
| 34 | + $text = false; |
| 35 | + |
| 36 | + $dbr = wfGetDB( DB_SLAVE ); |
| 37 | + |
| 38 | + $res = $dbr->select( |
| 39 | + 'live_translate_memories', |
| 40 | + array( 'memory_id', 'memory_local', 'memory_type' ), |
| 41 | + array( 'memory_location' => $location ), |
| 42 | + __METHOD__, |
| 43 | + array( 'LIMIT' => '1' ) |
| 44 | + ); |
| 45 | + |
| 46 | + foreach ( $res as $tm ) { |
| 47 | + if ( $tm->memory_local != "0" ) { |
| 48 | + // Obtain the contents of the article. |
| 49 | + $title = Title::newFromText( $location, NS_MAIN ); |
| 50 | + |
| 51 | + if ( is_object( $title ) && $title->exists() ) { |
| 52 | + $article = new Article( $title ); |
| 53 | + $text = $article->getContent(); |
| 54 | + } |
| 55 | + } |
| 56 | + else { |
| 57 | + // Make an HTTP request to get the file contents. False is returned on failiure. |
| 58 | + $text = Http::get( $location ); |
| 59 | + } |
| 60 | + |
| 61 | + if ( $text !== false ) { |
| 62 | + // If the text was obtained, parse it to a translation memory and import it into the db. |
| 63 | + $parser = LTTMParser::newFromType( $tm->memory_type ); |
| 64 | + $this->doTMImport( $parser->parse( $text ), $tm->memory_id ); |
| 65 | + } |
| 66 | + |
| 67 | + break; |
| 68 | + } |
| 69 | + } |
| 70 | + } |
| 71 | + |
| 72 | + /** |
| 73 | + * Imports a translation memory into the database. |
| 74 | + * |
| 75 | + * @since 0.4 |
| 76 | + * |
| 77 | + * @param LTTranslationMemory $tm |
| 78 | + * @param integer $memoryId |
| 79 | + */ |
| 80 | + protected function doTMImport( LTTranslationMemory $tm, $memoryId ) { |
| 81 | + $dbw = wfGetDB( DB_MASTER ); |
| 82 | + |
| 83 | + // Delete the memory from the db if already there. |
| 84 | + $dbw->delete( |
| 85 | + 'live_translate', |
| 86 | + array( 'memory_id' => $memoryId ) |
| 87 | + ); |
| 88 | + |
| 89 | + $idOffset = ( $memoryId - 1 ) * 100000; |
| 90 | + $wordId = 0; |
| 91 | + |
| 92 | + $dbw->begin(); |
| 93 | + |
| 94 | + // Insert the memory in the db. |
| 95 | + foreach ( $tm->getTranslationUnits() as $tu ) { |
| 96 | + if ( !$tu->isSignificant() ) { |
| 97 | + continue; |
| 98 | + } |
| 99 | + |
| 100 | + foreach ( $tu->getVariants() as $language => $translations ) { |
| 101 | + $primary = 1; |
| 102 | + |
| 103 | + foreach ( $translations as $translation ) { |
| 104 | + $dbw->insert( |
| 105 | + 'live_translate', |
| 106 | + array( |
| 107 | + 'word_id' => $idOffset + $wordId, |
| 108 | + 'word_language' => $this->cleanLanguage( $language ), |
| 109 | + 'word_translation' => $translation, |
| 110 | + 'word_primary' => $primary, |
| 111 | + 'memory_id' => $memoryId |
| 112 | + ) |
| 113 | + ); |
| 114 | + |
| 115 | + $primary = 0; |
| 116 | + } |
| 117 | + } |
| 118 | + |
| 119 | + $wordId++; |
| 120 | + |
| 121 | + if ( $wordId % 500 == 0 ) { |
| 122 | + $dbw->commit(); |
| 123 | + $dbw->begin(); |
| 124 | + } |
| 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 | + ); |
| 135 | + |
| 136 | + $dbw->commit(); |
| 137 | + } |
| 138 | + |
| 139 | + /** |
| 140 | + * Cleans the language code. |
| 141 | + * |
| 142 | + * @since 0.4 |
| 143 | + * |
| 144 | + * @param string language |
| 145 | + * |
| 146 | + * @return string |
| 147 | + */ |
| 148 | + protected function cleanLanguage( $language ) { |
| 149 | + $language = strtolower( $language ); |
| 150 | + $mappings = LiveTranslateFunctions::getInputLangMapping(); |
| 151 | + |
| 152 | + if ( array_key_exists( $language, $mappings ) ) { |
| 153 | + $language = $mappings[$language]; |
| 154 | + } |
| 155 | + |
| 156 | + return $language; |
| 157 | + } |
| 158 | + |
| 159 | + public function getAllowedParams() { |
| 160 | + return array( |
| 161 | + 'source' => array( |
| 162 | + ApiBase::PARAM_TYPE => 'string', |
| 163 | + ApiBase::PARAM_ISMULTI => true, |
| 164 | + //ApiBase::PARAM_REQUIRED => true, |
| 165 | + ), |
| 166 | + ); |
| 167 | + } |
| 168 | + |
| 169 | + public function getParamDescription() { |
| 170 | + return array( |
| 171 | + 'source' => 'Location of the translation memory. Multiple sources can be provided using the | delimiter.', |
| 172 | + ); |
| 173 | + } |
| 174 | + |
| 175 | + public function getDescription() { |
| 176 | + return array( |
| 177 | + 'Imports one or more translation memories.' |
| 178 | + ); |
| 179 | + } |
| 180 | + |
| 181 | + public function getPossibleErrors() { |
| 182 | + return array_merge( parent::getPossibleErrors(), array( |
| 183 | + array( 'missingparam', 'source' ), |
| 184 | + ) ); |
| 185 | + } |
| 186 | + |
| 187 | + protected function getExamples() { |
| 188 | + return array( |
| 189 | + 'api.php?action=importtms&source=http://localhost/tmx.xml', |
| 190 | + 'api.php?action=importtms&source=http://localhost/tmx.xml|http://localhost/google.csv|Live Translate Dictionary', |
| 191 | + ); |
| 192 | + } |
| 193 | + |
| 194 | + public function getVersion() { |
| 195 | + return __CLASS__ . ': $Id: ApiImportTranslationMemories.php 80193 2011-01-13 22:00:25Z jeroendedauw $'; |
| 196 | + } |
| 197 | + |
| 198 | +} |
\ No newline at end of file |
Property changes on: tags/extensions/LiveTranslate/REL_0_4/api/ApiImportTranslationMemories.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 199 | + native |
Index: tags/extensions/LiveTranslate/REL_0_4/api/ApiLiveTranslate.php |
— | — | @@ -0,0 +1,138 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * API module to get special translations stored by the Live Translate extension. |
| 6 | + * |
| 7 | + * @since 0.1 |
| 8 | + * |
| 9 | + * @file ApiLiveTranslate.php |
| 10 | + * @ingroup LiveTranslate |
| 11 | + * |
| 12 | + * @author Jeroen De Dauw < jeroendedauw@gmail.com > |
| 13 | + */ |
| 14 | +class ApiLiveTranslate extends ApiBase { |
| 15 | + |
| 16 | + public function __construct( $main, $action ) { |
| 17 | + parent::__construct( $main, $action ); |
| 18 | + } |
| 19 | + |
| 20 | + public function execute() { |
| 21 | + $params = $this->extractRequestParams(); |
| 22 | + |
| 23 | + // In MW 1.17 and above ApiBase::PARAM_REQUIRED can be used, this is for b/c with 1.16. |
| 24 | + foreach ( array( 'from', 'to', 'words' ) as $requiredParam ) { |
| 25 | + if ( !isset( $params[$requiredParam] ) ) { |
| 26 | + $this->dieUsageMsg( array( 'missingparam', $requiredParam ) ); |
| 27 | + } |
| 28 | + } |
| 29 | + |
| 30 | + $dbr = wfGetDB( DB_SLAVE ); |
| 31 | + |
| 32 | + foreach ( array_unique( $params['words'] ) as $word ) { |
| 33 | + $source = $dbr->selectRow( |
| 34 | + 'live_translate', |
| 35 | + array( 'word_id' ), |
| 36 | + array( |
| 37 | + 'word_language' => $params['from'], |
| 38 | + 'word_translation' => $word |
| 39 | + ) |
| 40 | + ); |
| 41 | + |
| 42 | + $toggledWord = false; |
| 43 | + |
| 44 | + if ( !$source ) { |
| 45 | + $toggledWord = LiveTranslateFunctions::getToggledCase( $word ); |
| 46 | + |
| 47 | + if ( $toggledWord ) { |
| 48 | + $source = $dbr->selectRow( |
| 49 | + 'live_translate', |
| 50 | + array( 'word_id' ), |
| 51 | + array( |
| 52 | + 'word_language' => $params['from'], |
| 53 | + 'word_translation' => $toggledWord |
| 54 | + ) |
| 55 | + ); |
| 56 | + } |
| 57 | + } |
| 58 | + |
| 59 | + if ( $source ) { |
| 60 | + $destination = $dbr->selectRow( |
| 61 | + 'live_translate', |
| 62 | + array( 'word_translation' ), |
| 63 | + array( |
| 64 | + 'word_language' => $params['to'], |
| 65 | + 'word_id' => $source->word_id, |
| 66 | + 'word_primary' => 1 |
| 67 | + ) |
| 68 | + ); |
| 69 | + |
| 70 | + if ( $destination ) { |
| 71 | + if ( $toggledWord ) { |
| 72 | + $translation = LiveTranslateFunctions::getToggledCase( $destination->word_translation ); |
| 73 | + |
| 74 | + if ( $translation ) { |
| 75 | + $destination->word_translation = $translation; |
| 76 | + } |
| 77 | + } |
| 78 | + |
| 79 | + $this->getResult()->addValue( |
| 80 | + 'translations', |
| 81 | + $word, |
| 82 | + $destination->word_translation |
| 83 | + ); |
| 84 | + } |
| 85 | + } |
| 86 | + } |
| 87 | + } |
| 88 | + |
| 89 | + public function getAllowedParams() { |
| 90 | + return array( |
| 91 | + 'from' => array( |
| 92 | + ApiBase::PARAM_TYPE => 'string', |
| 93 | + //ApiBase::PARAM_REQUIRED => true, |
| 94 | + ), |
| 95 | + 'to' => array( |
| 96 | + ApiBase::PARAM_TYPE => 'string', |
| 97 | + //ApiBase::PARAM_REQUIRED => true, |
| 98 | + ), |
| 99 | + 'words' => array( |
| 100 | + ApiBase::PARAM_TYPE => 'string', |
| 101 | + ApiBase::PARAM_ISMULTI => true, |
| 102 | + //ApiBase::PARAM_REQUIRED => true, |
| 103 | + ), |
| 104 | + ); |
| 105 | + } |
| 106 | + |
| 107 | + public function getParamDescription() { |
| 108 | + return array( |
| 109 | + 'from' => 'Source language', |
| 110 | + 'to' => 'Destination language', |
| 111 | + 'words' => 'The words to translate. Delimitered by |', |
| 112 | + ); |
| 113 | + } |
| 114 | + |
| 115 | + public function getDescription() { |
| 116 | + return array( |
| 117 | + 'Returns the available translations of the provided words in the source language in the destiniation language.' |
| 118 | + ); |
| 119 | + } |
| 120 | + |
| 121 | + public function getPossibleErrors() { |
| 122 | + return array_merge( parent::getPossibleErrors(), array( |
| 123 | + array( 'missingparam', 'from' ), |
| 124 | + array( 'missingparam', 'to' ), |
| 125 | + array( 'missingparam', 'words' ), |
| 126 | + ) ); |
| 127 | + } |
| 128 | + |
| 129 | + protected function getExamples() { |
| 130 | + return array( |
| 131 | + 'api.php?action=livetranslate&from=English&to=Dutch&words=In|Your|Example', |
| 132 | + ); |
| 133 | + } |
| 134 | + |
| 135 | + public function getVersion() { |
| 136 | + return __CLASS__ . ': $Id: ApiLiveTranslate.php 80263 2011-01-14 14:24:24Z jeroendedauw $'; |
| 137 | + } |
| 138 | + |
| 139 | +} |
Property changes on: tags/extensions/LiveTranslate/REL_0_4/api/ApiLiveTranslate.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 140 | + native |
Index: tags/extensions/LiveTranslate/REL_0_4/LiveTranslate.sql |
— | — | @@ -0,0 +1,22 @@ |
| 2 | +-- MySQL version of the database schema for the Live Translate extension. |
| 3 | + |
| 4 | +-- Special translations table. |
| 5 | +CREATE TABLE IF NOT EXISTS /*$wgDBprefix*/live_translate ( |
| 6 | + word_id INT(8) unsigned NOT NULL, |
| 7 | + word_language VARCHAR(255) NOT NULL, |
| 8 | + word_translation VARCHAR(255) NOT NULL, |
| 9 | + word_primary INT(1) unsigned NOT NULL, |
| 10 | + memory_id INT(4) unsigned NOT NULL |
| 11 | +) /*$wgDBTableOptions*/; |
| 12 | + |
| 13 | +-- Table to keep track of translation memories for the special words. |
| 14 | +CREATE TABLE IF NOT EXISTS /*$wgDBprefix*/live_translate_memories ( |
| 15 | + memory_id INT(4) unsigned NOT NULL auto_increment PRIMARY KEY, |
| 16 | + memory_type INT(2) unsigned NOT NULL, |
| 17 | + memory_location VARCHAR(255) 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 |
| 21 | +) /*$wgDBTableOptions*/; |
| 22 | + |
| 23 | +INSERT INTO /*$wgDBprefix*/live_translate_memories VALUES (NULL, 0, "Live Translate Dictionary", 1, 0, 0); |
\ No newline at end of file |
Property changes on: tags/extensions/LiveTranslate/REL_0_4/LiveTranslate.sql |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 24 | + native |
Index: tags/extensions/LiveTranslate/REL_0_4/README |
— | — | @@ -0,0 +1,47 @@ |
| 2 | +These is the readme file for the Live Translate extension. |
| 3 | + |
| 4 | +Extension page on mediawiki.org: http://www.mediawiki.org/wiki/Extension:Live_Translate |
| 5 | +Latest version of the readme file: http://svn.wikimedia.org/viewvc/mediawiki/trunk/extensions/LiveTranslate/README?view=co |
| 6 | + |
| 7 | +== About == |
| 8 | + |
| 9 | +Live Translate is a lightweight extension to live translate articles using the Google Translate service. |
| 10 | + |
| 11 | +== Usage == |
| 12 | + |
| 13 | +Live Translate adds a "Translate" button to the top right-hand corner of wiki pages, together with a dropdown |
| 14 | +menu that allows you to select the target language. Hitting the "Translate" button will cause the text in the |
| 15 | +wiki page to be translated to the selected destination language within the browser (it will not modify the |
| 16 | +original source text in any way). The source language will be assumed to be the wiki's main language, unless |
| 17 | +the wiki page's name ends with a "/" and then a language code, e.g., "Main Page/de" - if that is the case, the |
| 18 | +wiki page's language will be assumed to be the one that corresponds to that language code. |
| 19 | + |
| 20 | +After a user hits the "Translate" button, another button, "Show original", will appear, which if pressed will |
| 21 | +return the display to its original language. |
| 22 | + |
| 23 | +=== Defining a translation dictionary === |
| 24 | + |
| 25 | +You can define a dictionary of "special words" for which you provide translations, and that will then be left |
| 26 | +alone by Google Translate. This dictionary is defined in a page within the wiki; by default the page is named |
| 27 | +"Live Translate Dictionary", but this name can be changed in LocalSettings.php. The contents of the page should |
| 28 | +be a list in CSV (comma-separated values) format, where the first row contains the set of relevant language codes, |
| 29 | +and the successive ones the translations. An example would be: |
| 30 | + |
| 31 | +<pre> |
| 32 | +en, nl, de |
| 33 | +Hello world, Hallo wereld, Hallo welt |
| 34 | +Awesome, Geweldig, Große |
| 35 | +</pre> |
| 36 | + |
| 37 | +The dictionary supports defining synonyms. You can add them using the | sign as delimiter. For example, if you |
| 38 | +want "fantastic" to be translated the same as "awesome", the above dictionary would change to: |
| 39 | + |
| 40 | +<pre> |
| 41 | +en, nl, de |
| 42 | +Hello world, Hallo wereld, Hallo welt |
| 43 | +Awesome|fantastic, Geweldig, Große |
| 44 | +</pre> |
| 45 | + |
| 46 | +This means that "fantastic" will be "handled" exactly the same as "Awesome" when translating from English to |
| 47 | +one of the other languages. When translating to English, the first word in the synonym list, in this case |
| 48 | +"Awesome", will be used. So translating the Dutch "Geweldig" to English will result in "Awesome". |