r80426 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r80425‎ | r80426 | r80427 >
Date:21:00, 16 January 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Tag for version 0.5.
Modified paths:
  • /tags/extensions/LiveTranslate/REL_0_5 (added) (history)
  • /tags/extensions/LiveTranslate/REL_0_5/COPYING (added) (history)
  • /tags/extensions/LiveTranslate/REL_0_5/INSTALL (added) (history)
  • /tags/extensions/LiveTranslate/REL_0_5/LiveTranslate.hooks.php (added) (history)
  • /tags/extensions/LiveTranslate/REL_0_5/LiveTranslate.i18n.php (added) (history)
  • /tags/extensions/LiveTranslate/REL_0_5/LiveTranslate.php (added) (history)
  • /tags/extensions/LiveTranslate/REL_0_5/LiveTranslate.sql (added) (history)
  • /tags/extensions/LiveTranslate/REL_0_5/LiveTranslate_Settings.php (added) (history)
  • /tags/extensions/LiveTranslate/REL_0_5/README (added) (history)
  • /tags/extensions/LiveTranslate/REL_0_5/RELEASE-NOTES (added) (history)
  • /tags/extensions/LiveTranslate/REL_0_5/api (added) (history)
  • /tags/extensions/LiveTranslate/REL_0_5/api/ApiImportTranslationMemories.php (added) (history)
  • /tags/extensions/LiveTranslate/REL_0_5/api/ApiLiveTranslate.php (added) (history)
  • /tags/extensions/LiveTranslate/REL_0_5/api/ApiQueryLiveTranslate.php (added) (history)
  • /tags/extensions/LiveTranslate/REL_0_5/includes (added) (history)
  • /tags/extensions/LiveTranslate/REL_0_5/includes/LT_GCSVParser.php (added) (history)
  • /tags/extensions/LiveTranslate/REL_0_5/includes/LT_LTFParser.php (added) (history)
  • /tags/extensions/LiveTranslate/REL_0_5/includes/LT_TMParser.php (added) (history)
  • /tags/extensions/LiveTranslate/REL_0_5/includes/LT_TMUnit.php (added) (history)
  • /tags/extensions/LiveTranslate/REL_0_5/includes/LT_TMXParser.php (added) (history)
  • /tags/extensions/LiveTranslate/REL_0_5/includes/LT_TranslationMemory.php (added) (history)
  • /tags/extensions/LiveTranslate/REL_0_5/includes/LiveTranslate_Functions.php (added) (history)
  • /tags/extensions/LiveTranslate/REL_0_5/includes/ext.livetranslate.js (added) (history)
  • /tags/extensions/LiveTranslate/REL_0_5/specials (added) (history)
  • /tags/extensions/LiveTranslate/REL_0_5/specials/SpecialLiveTranslate.php (added) (history)
  • /tags/extensions/LiveTranslate/REL_0_5/sql (added) (history)
  • /tags/extensions/LiveTranslate/REL_0_5/sql/LT_IndexWordTranslation.sql (added) (history)
  • /tags/extensions/LiveTranslate/REL_0_5/sql/LT_addTMField.sql (added) (history)

Diff [purge]

Index: tags/extensions/LiveTranslate/REL_0_5/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_5/sql/LT_IndexWordTranslation.sql
___________________________________________________________________
Added: svn:eol-style
13 + native
Index: tags/extensions/LiveTranslate/REL_0_5/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_5/sql/LT_addTMField.sql
___________________________________________________________________
Added: svn:eol-style
14 + native
Index: tags/extensions/LiveTranslate/REL_0_5/LiveTranslate.i18n.php
@@ -0,0 +1,574 @@
 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+ 'livetranslate-dictionary-goto-edit' => 'Зьмяніць памяці перакладаў.',
 87+ 'special-livetranslate' => 'Пераклад на ляту',
 88+ 'livetranslate-tmtype-ltf' => 'Фармат перакладу на ляту',
 89+ 'livetranslate-tmtype-tmx' => 'Абмен памяцьцю перакладаў',
 90+ 'livetranslate-tmtype-gcsv' => 'Google CSV',
 91+ 'livetranslate-special-no-tms-yet' => 'Пакуль што няма памяці перакладаў.',
 92+ 'livetranslate-special-button' => 'Захаваць і абнавіць',
 93+ 'livetranslate-special-type' => 'Тып',
 94+ 'livetranslate-special-location' => 'Месцазнаходжаньне',
 95+ 'livetranslate-special-remove' => 'Выдаліць',
 96+ 'livetranslate-special-local' => 'Лякальная',
 97+ 'livetranslate-special-add-tm' => 'Дадаць новую памяць перакладаў',
 98+ 'livetranslate-special-current-tms' => 'Існуючыя памяці перакладаў',
 99+ 'livetranslate-special-tms-update' => 'Абнавіць памяці перакладаў',
 100+ 'livetranslate-special-update' => 'Абнавіць памяці перакладаў',
 101+ 'livetranslate-importtms-param-miscmatch' => 'Несупадзеньне паміж колькасьцю знаходжаньняў і тыпамі',
 102+);
 103+
 104+/** Bulgarian (Български)
 105+ * @author DCLXVI
 106+ */
 107+$messages['bg'] = array(
 108+ 'livetranslate-button-translate' => 'Превеждане',
 109+ 'livetranslate-button-translating' => 'Превеждане...',
 110+);
 111+
 112+/** Breton (Brezhoneg)
 113+ * @author Fulup
 114+ */
 115+$messages['br'] = array(
 116+ 'livetranslate-desc' => 'Aotren a ra treiñ danvez ur bajenn war-eeun en ur ober gant servij treiñ Google',
 117+ 'livetranslate-translate-to' => 'Treiñ ar bajenn-mañ e',
 118+ 'livetranslate-button-translate' => 'Treiñ',
 119+ 'livetranslate-button-translating' => 'O treiñ...',
 120+ 'livetranslate-button-revert' => 'Diskouez ar stumm orin',
 121+ '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.',
 122+ 'livetranslate-dictionary-empty' => 'Ger ebet er geriadur evit c\'hoazh. Klikit war an ivinell "kemmañ" evit ouzhpennañ unan.',
 123+ '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.',
 124+ '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.",
 125+);
 126+
 127+/** Bosnian (Bosanski)
 128+ * @author CERminator
 129+ */
 130+$messages['bs'] = array(
 131+ 'livetranslate-desc' => 'Omogućuje prevođenje uživo sadržaja stranice koristeći uslugu Google Translate',
 132+ 'livetranslate-translate-to' => 'Prevedi ovu stranicu na',
 133+ 'livetranslate-button-translate' => 'Prevedi',
 134+ 'livetranslate-button-translating' => 'Prevodim...',
 135+ 'livetranslate-button-revert' => 'Prikaži original',
 136+ '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.',
 137+ 'livetranslate-dictionary-empty' => "Još uvijek nema riječi u rječniku. Kliknite na jezičak ''uredi'' da ih dodate.",
 138+ '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.',
 139+ '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.',
 140+);
 141+
 142+/** German (Deutsch)
 143+ * @author Kghbln
 144+ */
 145+$messages['de'] = array(
 146+ 'livetranslate-desc' => 'Ermöglicht die unmittelbare Übersetzung des Seiteninhalts mit „Google Übersetzer“',
 147+ 'livetranslate-translate-to' => 'Diese Seite in folgende Sprache übersetzen:',
 148+ 'livetranslate-button-translate' => 'Übersetze',
 149+ 'livetranslate-button-translating' => 'Übersetze …',
 150+ 'livetranslate-button-revert' => 'Originalinhalt anzeigen',
 151+ '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.',
 152+ 'livetranslate-dictionary-empty' => 'Momentan befinden sich keine Vokabeln im Wörterbuch. Auf „Bearbeiten“ klicken, um welche hinzuzufügen.',
 153+ '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.',
 154+ '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.',
 155+ 'livetranslate-dictionary-goto-edit' => 'Die Übersetzungsspeicher anpassen.',
 156+ 'special-livetranslate' => 'Direktübersetzung',
 157+ 'livetranslate-tmtype-ltf' => 'Live Translate format',
 158+ 'livetranslate-tmtype-tmx' => 'Translation Memory eXchange',
 159+ 'livetranslate-tmtype-gcsv' => 'Google-CSV',
 160+ 'livetranslate-special-no-tms-yet' => 'Momentan sind keine Übersetzungsspeicher vorhanden.',
 161+ 'livetranslate-special-button' => 'Speichern und aktualisieren',
 162+ 'livetranslate-special-type' => 'Eingeben',
 163+ 'livetranslate-special-location' => 'Ort',
 164+ 'livetranslate-special-remove' => 'Entfernen',
 165+ 'livetranslate-special-local' => 'Lokal',
 166+ 'livetranslate-special-add-tm' => 'Einen neuen Übersetzungsspeicher anlegen',
 167+ 'livetranslate-special-current-tms' => 'Vorhandene Übersetzungsspeicher',
 168+ 'livetranslate-special-tms-update' => 'Übersetzungsspeicher aktualisieren',
 169+ 'livetranslate-special-update' => 'Übersetzungsspeicher aktualisieren',
 170+ 'livetranslate-importtms-param-miscmatch' => 'Missverhältnis zwischen Anzahl an Übersetzungsspeichern und Übersetzungsspeicherarten',
 171+);
 172+
 173+/** Lower Sorbian (Dolnoserbski)
 174+ * @author Michawiki
 175+ */
 176+$messages['dsb'] = array(
 177+ 'livetranslate-desc' => 'Zmóžnja direktne pśełožowanje wopśimjeśa boka z pomocu słužby "Google Translate"',
 178+ 'livetranslate-translate-to' => 'Pśełož toś ten boko do',
 179+ 'livetranslate-button-translate' => 'Pśełožyś',
 180+ 'livetranslate-button-translating' => 'Pśełožujo se...',
 181+ 'livetranslate-button-revert' => 'Original pokazaś',
 182+ 'livetranslate-dictionary-error' => 'Słownik za Live Translate njedajo se zacytaś. Jogo słowa njezapśimuju se za pśełožowański proces.',
 183+ 'livetranslate-dictionary-empty' => 'Hyšći njejsu žedne słowa w słowniku. Klikni na rejtark "wobźěłaś", aby někotare dodał.',
 184+ '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ł.',
 185+ '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.',
 186+ 'livetranslate-dictionary-goto-edit' => 'Pśełožowańske składowaki změniś.',
 187+ 'special-livetranslate' => 'Direktne přełožowanje',
 188+ 'livetranslate-tmtype-ltf' => 'Live Translate format',
 189+ 'livetranslate-tmtype-tmx' => 'Translation Memory eXchange',
 190+ 'livetranslate-tmtype-gcsv' => 'Google CSV',
 191+ 'livetranslate-special-no-tms-yet' => 'Pśełožowańske składowaki hyšći njejsu.',
 192+ 'livetranslate-special-button' => 'Składowaś a aktualizěrowaś',
 193+ 'livetranslate-special-type' => 'Typ',
 194+ 'livetranslate-special-location' => 'Městno',
 195+ 'livetranslate-special-remove' => 'Wótpóraś',
 196+ 'livetranslate-special-local' => 'Lokalny',
 197+ 'livetranslate-special-add-tm' => 'Nowy pśełožowański składowak pśidaś',
 198+ 'livetranslate-special-current-tms' => 'Eksistěrujuce pśełožowańske składowaki',
 199+ 'livetranslate-special-tms-update' => 'Pséłožowańske składowaki aktualizěrowaś',
 200+ 'livetranslate-special-update' => 'Pséłožowańske składowaki aktualizěrowaś',
 201+ 'livetranslate-importtms-param-miscmatch' => 'Njedobry poměr mjazy licbu městnow a typow',
 202+);
 203+
 204+/** Basque (Euskara)
 205+ * @author An13sa
 206+ */
 207+$messages['eu'] = array(
 208+ 'livetranslate-button-translate' => 'Itzuli',
 209+ 'livetranslate-button-translating' => 'Itzultzen...',
 210+ 'livetranslate-button-revert' => 'Jatorrizkoa erakutsi',
 211+);
 212+
 213+/** French (Français)
 214+ * @author Crochet.david
 215+ * @author Sherbrooke
 216+ */
 217+$messages['fr'] = array(
 218+ 'livetranslate-desc' => 'Permet la traduction immédiate du contenu de la page en utilisant le service de traduction de Google',
 219+ 'livetranslate-translate-to' => 'Traduire cette page en',
 220+ 'livetranslate-button-translate' => 'Traduire',
 221+ 'livetranslate-button-translating' => 'Traduction en cours...',
 222+ 'livetranslate-button-revert' => 'Afficher l’original',
 223+ '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.",
 224+ 'livetranslate-dictionary-empty' => "Il n'y a aucun mot dans le dictionnaire encore. Cliquez sur l'onglet « Modifier » pour en ajouter.",
 225+ '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.",
 226+ '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.",
 227+ 'special-livetranslate' => 'Live translate',
 228+ 'livetranslate-tmtype-ltf' => 'Format Live Translate',
 229+ 'livetranslate-tmtype-tmx' => 'Translation Memory eXchange',
 230+ 'livetranslate-tmtype-gcsv' => 'Google CSV',
 231+ 'livetranslate-special-no-tms-yet' => "Il n'ya pas de mémoires de traduction pour le moment.",
 232+ 'livetranslate-special-button' => 'Enregistrer et mettre à jour',
 233+ 'livetranslate-special-type' => 'Type',
 234+ 'livetranslate-special-location' => 'Localisation',
 235+ 'livetranslate-special-remove' => 'Enlever',
 236+ 'livetranslate-special-add-tm' => 'Ajouter une nouvelle mémoire de traduction',
 237+ 'livetranslate-special-current-tms' => 'Mémoires de traduction existantes',
 238+ 'livetranslate-special-tms-update' => 'Mise à jour de mémoires de traduction',
 239+ 'livetranslate-special-update' => 'Mise à jour de mémoires de traduction',
 240+ 'livetranslate-importtms-param-miscmatch' => "Incompatibilité entre la quantité d'emplacements et les types",
 241+);
 242+
 243+/** Galician (Galego)
 244+ * @author Toliño
 245+ */
 246+$messages['gl'] = array(
 247+ 'livetranslate-desc' => 'Activa a tradución en vivo do contido dunha páxina mediante o servizo de tradución do Google',
 248+ 'livetranslate-translate-to' => 'Traducir esta páxina ao',
 249+ 'livetranslate-button-translate' => 'Traducir',
 250+ 'livetranslate-button-translating' => 'Traducindo...',
 251+ 'livetranslate-button-revert' => 'Mostrar o orixinal',
 252+);
 253+
 254+/** Swiss German (Alemannisch)
 255+ * @author Als-Holder
 256+ */
 257+$messages['gsw'] = array(
 258+ 'livetranslate-desc' => 'Macht di diräkt Ibersetzig vum Syteninhalt megli mit „Google Ibersetzer“',
 259+ 'livetranslate-translate-to' => 'Die Syte ibersetze in',
 260+ 'livetranslate-button-translate' => 'Ibersetze',
 261+ 'livetranslate-button-translating' => 'Am Ibersetze …',
 262+ 'livetranslate-button-revert' => 'Originalinhalt aazeige',
 263+ '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.',
 264+ 'livetranslate-dictionary-empty' => 'Zurzyt het s kei Vokable im Werterbuech. Uf „Bearbeite“ klicke go ne baar yyfiege.',
 265+ '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.',
 266+ '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.',
 267+);
 268+
 269+/** Upper Sorbian (Hornjoserbsce)
 270+ * @author Michawiki
 271+ */
 272+$messages['hsb'] = array(
 273+ 'livetranslate-desc' => 'Zmóžnja hnydomne přełožowanje wobsaha strony z pomocu słužby "Google Translate"',
 274+ 'livetranslate-translate-to' => 'Přełož tutu stronu do',
 275+ 'livetranslate-button-translate' => 'Přełožić',
 276+ 'livetranslate-button-translating' => 'Přełožuje so...',
 277+ 'livetranslate-button-revert' => 'Original pokazać',
 278+ 'livetranslate-dictionary-error' => 'Słownik za Live Translate njeda so začitać. Jeho słowa so za přełožowanski proces njewobkedźbuja.',
 279+ 'livetranslate-dictionary-empty' => 'Hišće žane słowa w słowniku njejsu. Klikń na rajtark "wobdźěłać", zo by někotre přidał.',
 280+ '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ł.',
 281+ '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.',
 282+ 'livetranslate-dictionary-goto-edit' => 'Pśełožowański składowak změniś.',
 283+ 'special-livetranslate' => 'Live translate',
 284+ 'livetranslate-tmtype-ltf' => 'Live Translate format',
 285+ 'livetranslate-tmtype-tmx' => 'Translation Memory eXchange',
 286+ 'livetranslate-tmtype-gcsv' => 'Google-CSV',
 287+ 'livetranslate-special-no-tms-yet' => 'Hišće přełožkowe składowaki njejsu.',
 288+ 'livetranslate-special-button' => 'Składować a aktualizować',
 289+ 'livetranslate-special-type' => 'Typ',
 290+ 'livetranslate-special-location' => 'Městno',
 291+ 'livetranslate-special-remove' => 'Wotstronić',
 292+ 'livetranslate-special-local' => 'Lokalny',
 293+ 'livetranslate-special-add-tm' => 'Nowy přełožkowy składowak přidać',
 294+ 'livetranslate-special-current-tms' => 'Eksistowace přełožkowe składowaki',
 295+ 'livetranslate-special-tms-update' => 'Přełožkowe składowaki aktualizować',
 296+ 'livetranslate-special-update' => 'Přełožkowe składowaki aktualizować',
 297+ 'livetranslate-importtms-param-miscmatch' => 'Njepoměr mjez ličbu městnow a typow',
 298+);
 299+
 300+/** Interlingua (Interlingua)
 301+ * @author McDutchie
 302+ */
 303+$messages['ia'] = array(
 304+ 'livetranslate-desc' => 'Permitte le traduction in directo de contento de paginas usante le servicio Google Translate',
 305+ 'livetranslate-translate-to' => 'Traducer iste pagina in',
 306+ 'livetranslate-button-translate' => 'Traducer',
 307+ 'livetranslate-button-translating' => 'Traduction in curso...',
 308+ 'livetranslate-button-revert' => 'Monstrar original',
 309+ 'livetranslate-dictionary-error' => 'Non poteva obtener le dictionario de traduction in directo. Nulle parola essera tractate como special durante le processo de traduction.',
 310+ 'livetranslate-dictionary-empty' => 'Le dictionario non ha ancora parolas. Clicca sur le scheda "modificar" pro adder alcunes.',
 311+ '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.',
 312+ '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.',
 313+ 'livetranslate-dictionary-goto-edit' => 'Modificar le memorias de traduction.',
 314+ 'special-livetranslate' => 'Traduction in directo',
 315+ 'livetranslate-tmtype-ltf' => 'Formato de traduction in directo',
 316+ 'livetranslate-tmtype-tmx' => 'Translation Memory eXchange',
 317+ 'livetranslate-tmtype-gcsv' => 'CSV de Google',
 318+ 'livetranslate-special-no-tms-yet' => 'Il non ha ancora memorias de traduction.',
 319+ 'livetranslate-special-button' => 'Salveguardar e actualisar',
 320+ 'livetranslate-special-type' => 'Typo',
 321+ 'livetranslate-special-location' => 'Loco',
 322+ 'livetranslate-special-remove' => 'Remover',
 323+ 'livetranslate-special-local' => 'Local',
 324+ 'livetranslate-special-add-tm' => 'Adder un nove memoria de traduction',
 325+ 'livetranslate-special-current-tms' => 'Memorias de traduction existente',
 326+ 'livetranslate-special-tms-update' => 'Actualisar memorias de traduction',
 327+ 'livetranslate-special-update' => 'Actualisar memorias de traduction',
 328+ 'livetranslate-importtms-param-miscmatch' => 'Le numero de locos differe del numero de typos',
 329+);
 330+
 331+/** Indonesian (Bahasa Indonesia)
 332+ * @author IvanLanin
 333+ */
 334+$messages['id'] = array(
 335+ 'livetranslate-desc' => 'Memungkinkan penerjemahan langsung konten halaman dengan menggunakan layanan Google Terjemahan',
 336+ 'livetranslate-translate-to' => 'Terjemahkan halaman ini ke',
 337+ 'livetranslate-button-translate' => 'Terjemahkan',
 338+ 'livetranslate-button-translating' => 'Menerjemahkan ...',
 339+ 'livetranslate-button-revert' => 'Tampilkan yang asli',
 340+ 'livetranslate-dictionary-error' => 'Tidak dapat memperoleh kamus penerjemahan langsung. Tidak ada kata yang diperlakukan secara khusus selama proses penerjemahan.',
 341+ 'livetranslate-dictionary-empty' => 'Belum tersedia kata dalam kamus. Klik tab "sunting" untuk menambahkan.',
 342+ 'livetranslate-dictionary-count' => 'Ada {{PLURAL:$1|$1 kata|$1 kata}} dalam $2 {{PLURAL:$2|bahasa|bahasa}}. Klik tab "sunting" untuk menambakan.',
 343+ '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.',
 344+ 'livetranslate-dictionary-goto-edit' => 'Modifikasi memori terjemahan.',
 345+ 'special-livetranslate' => 'Terjemahan langsung',
 346+ 'livetranslate-tmtype-ltf' => 'Format Terjemahan Langsung',
 347+ 'livetranslate-tmtype-tmx' => 'Translation Memory eXchange',
 348+ 'livetranslate-tmtype-gcsv' => 'Google CSV',
 349+ 'livetranslate-special-no-tms-yet' => 'Memori terjemahan belum tersedia.',
 350+ 'livetranslate-special-button' => 'Simpan dan perbarui',
 351+ 'livetranslate-special-type' => 'Jenis',
 352+ 'livetranslate-special-location' => 'Lokasi',
 353+ 'livetranslate-special-remove' => 'Hapus',
 354+ 'livetranslate-special-local' => 'Lokal',
 355+ 'livetranslate-special-add-tm' => 'Tambahkan memori terjemahan baru',
 356+ 'livetranslate-special-current-tms' => 'Memori terjemahan yang ada',
 357+ 'livetranslate-special-tms-update' => 'Perbarui memori terjemahan',
 358+ 'livetranslate-special-update' => 'Perbarui memori terjemahan',
 359+ 'livetranslate-importtms-param-miscmatch' => 'Jumlah lokasi dan jenis tidak sesuai',
 360+);
 361+
 362+/** Italian (Italiano)
 363+ * @author Beta16
 364+ */
 365+$messages['it'] = array(
 366+ 'livetranslate-button-translate' => 'Traduci',
 367+ 'livetranslate-button-translating' => 'Traduzione in corso...',
 368+);
 369+
 370+/** Japanese (日本語)
 371+ * @author Ohgi
 372+ */
 373+$messages['ja'] = array(
 374+ 'livetranslate-translate-to' => 'このページを翻訳',
 375+ 'livetranslate-button-translate' => '翻訳',
 376+ 'livetranslate-button-translating' => '翻訳中...',
 377+);
 378+
 379+/** Luxembourgish (Lëtzebuergesch)
 380+ * @author Robby
 381+ */
 382+$messages['lb'] = array(
 383+ 'livetranslate-desc' => 'Erméiglecht d\'live Iwwersetzen vu Säiteninhalt mam Service "Google Translate"',
 384+ 'livetranslate-translate-to' => 'Iwwersetzt dës Säit op',
 385+ 'livetranslate-button-translate' => 'Iwwersetzen',
 386+ 'livetranslate-button-translating' => 'Iwwersetzen...',
 387+ 'livetranslate-button-revert' => "D'Original weisen",
 388+ 'livetranslate-dictionary-error' => 'De Live-Iwwersetzungs-Dictionnaire gouf net fonnt. Keng Wierder gi bei der Iwwersetzung als spezial ugekuckt.',
 389+ 'livetranslate-dictionary-empty' => 'Et gëtt nach keng Wierder am Dictionnaire. Klickt op den "Änneren"-Tab fir der derbäizesetzen.',
 390+ '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.',
 391+ '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.",
 392+);
 393+
 394+/** Macedonian (Македонски)
 395+ * @author Bjankuloski06
 396+ */
 397+$messages['mk'] = array(
 398+ 'livetranslate-desc' => 'Овозможува преведување на содржината на една страница во живо, користејќи Google Translate',
 399+ 'livetranslate-translate-to' => 'Преведи ја страницава на',
 400+ 'livetranslate-button-translate' => 'Преведи',
 401+ 'livetranslate-button-translating' => 'Преведувам...',
 402+ 'livetranslate-button-revert' => 'Прикажи изворно',
 403+ 'livetranslate-dictionary-error' => 'Не можев да го добијам речникот за преведување во живо. Ниеден збор нема да се смета за посебен во текот на преводната постапка.',
 404+ 'livetranslate-dictionary-empty' => 'Сè уште нема зборови во речникот. Стиснете на јазичето „уреди“ и додајте некои.',
 405+ 'livetranslate-dictionary-count' => 'Има {{PLURAL:$1|$1 збор|$1 збора}} на $2 {{PLURAL:$2|јазик|јазици}}. Ситиснете на јазичето „уреди“ за да додадете уште.',
 406+ 'livetranslate-dictionary-unallowed-langs' => '{{PLURAL:$2|Овој јазик моментално не е зададен|Овие јазици моментално не се зададени}} како допуштена преводна одредница: $1. Изменете ги допуштените јазици во вики-поставките, или пак отстранете ги постоечкиве од речникот.',
 407+ 'livetranslate-dictionary-goto-edit' => 'Измени ги преводните памтила.',
 408+ 'special-livetranslate' => 'Преведување во живо',
 409+ 'livetranslate-tmtype-ltf' => 'Формат на преведувањето во живо',
 410+ 'livetranslate-tmtype-tmx' => 'Translation Memory eXchange',
 411+ 'livetranslate-tmtype-gcsv' => 'Google CSV',
 412+ 'livetranslate-special-no-tms-yet' => 'Сè уште нема преводни памтила',
 413+ 'livetranslate-special-button' => 'Зачувај и поднови',
 414+ 'livetranslate-special-type' => 'Тип',
 415+ 'livetranslate-special-location' => 'Место',
 416+ 'livetranslate-special-remove' => 'Отстрани',
 417+ 'livetranslate-special-local' => 'Локално',
 418+ 'livetranslate-special-add-tm' => 'Додај ново преводно памтило',
 419+ 'livetranslate-special-current-tms' => 'Постоечки преводни памтила',
 420+ 'livetranslate-special-tms-update' => 'Поднови преводни памтила',
 421+ 'livetranslate-special-update' => 'Поднови преводни памтила',
 422+ 'livetranslate-importtms-param-miscmatch' => 'Бројот на местата и бројот на типовите не се совпаѓаат',
 423+);
 424+
 425+/** Dutch (Nederlands)
 426+ * @author McDutchie
 427+ * @author SPQRobin
 428+ * @author Siebrand
 429+ */
 430+$messages['nl'] = array(
 431+ 'livetranslate-desc' => 'Maakt het mogelijk paginainhoud live te vertalen met behulp van de dienst Google Translate',
 432+ 'livetranslate-translate-to' => 'Pagina vertalen in het',
 433+ 'livetranslate-button-translate' => 'Vertalen',
 434+ 'livetranslate-button-translating' => 'Bezig met vertalen...',
 435+ 'livetranslate-button-revert' => 'Origineel weergeven',
 436+ '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.',
 437+ 'livetranslate-dictionary-empty' => 'Er zijn nog geen woorden in het woordenboek. Klik op de tab "bewerken" om woorden toe te voegen.',
 438+ '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.',
 439+ '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.',
 440+ 'livetranslate-dictionary-goto-edit' => 'Vertaalgeheugens wijzigen.',
 441+ 'special-livetranslate' => 'Live vertalen',
 442+ 'livetranslate-tmtype-ltf' => 'Live Vertalen-opmaak',
 443+ 'livetranslate-tmtype-tmx' => 'Translation Memory eXchange',
 444+ 'livetranslate-tmtype-gcsv' => 'Google CSV',
 445+ 'livetranslate-special-no-tms-yet' => 'Er zijn nog geen vertaalgeheugens.',
 446+ 'livetranslate-special-button' => 'Opslaan en bijwerken',
 447+ 'livetranslate-special-type' => 'Type',
 448+ 'livetranslate-special-location' => 'Locatie',
 449+ 'livetranslate-special-remove' => 'Verwijderen',
 450+ 'livetranslate-special-local' => 'Lokaal',
 451+ 'livetranslate-special-add-tm' => 'Nieuw vertaalgeheugen toevoegen',
 452+ 'livetranslate-special-current-tms' => 'Bestaande vertaalgeheugens',
 453+ 'livetranslate-special-tms-update' => 'Vertaalgeheugens bijwerken',
 454+ 'livetranslate-special-update' => 'Vertaalgeheugens bijwerken',
 455+ 'livetranslate-importtms-param-miscmatch' => 'Er is een verschil tussen het aantal locaties en typen',
 456+);
 457+
 458+/** Norwegian (bokmål)‬ (‪Norsk (bokmål)‬)
 459+ * @author Nghtwlkr
 460+ */
 461+$messages['no'] = array(
 462+ 'livetranslate-desc' => 'Aktiverer live-oversettelse av sideinnhold ved hjelp av tjenesten Google Translate',
 463+ 'livetranslate-translate-to' => 'Oversett denne siden til',
 464+ 'livetranslate-button-translate' => 'Oversett',
 465+ 'livetranslate-button-translating' => 'Oversetter...',
 466+ 'livetranslate-button-revert' => 'Vis opprinnelig',
 467+ 'livetranslate-dictionary-error' => 'Kunne ikke få tak i sanntidsoversettelsesordlisten. Ingen ord vil bli behandlet som spesielle under oversettelsesprosessen.',
 468+ 'livetranslate-dictionary-empty' => 'Det er ingen ord i ordlisten ennå. Klikk på «rediger»-fanen for å legge til noen.',
 469+ '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.',
 470+ '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.',
 471+);
 472+
 473+/** Polish (Polski)
 474+ * @author Byulent
 475+ * @author Sp5uhe
 476+ */
 477+$messages['pl'] = array(
 478+ 'livetranslate-desc' => 'Włącza tłumaczenie zawartości strony na żywo z wykorzystaniem serwisu tłumaczącego Google',
 479+ 'livetranslate-translate-to' => 'Przetłumacz tę stronę na',
 480+ 'livetranslate-button-translate' => 'Tłumacz',
 481+ 'livetranslate-button-translating' => 'Tłumaczenie...',
 482+ 'livetranslate-button-revert' => 'Pokaż w oryginale',
 483+ '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.',
 484+ 'livetranslate-dictionary-empty' => 'Na razie brak jest jeszcze słów w słowniku. Kliknij zakładkę „Edytuj“ aby jakieś dodać.',
 485+ '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.',
 486+ '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.',
 487+);
 488+
 489+/** Piedmontese (Piemontèis)
 490+ * @author Dragonòt
 491+ */
 492+$messages['pms'] = array(
 493+ 'livetranslate-desc' => 'A abìlita viragi dal viv ëd contnù ëd pàgine an dovrand ël sërvissi Google Translate',
 494+ 'livetranslate-translate-to' => 'Vòlta sta pàgina an',
 495+ 'livetranslate-button-translate' => 'Traduv',
 496+ 'livetranslate-button-translating' => 'Volté...',
 497+ 'livetranslate-button-revert' => 'Mosta original',
 498+ '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.',
 499+ 'livetranslate-dictionary-empty' => 'A-i é pa anco\' gnun-e paròle ant ël dissionari. Sgnaca ël boton "modìfica" për giuntene quaidun-e.',
 500+ '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.',
 501+ '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.",
 502+);
 503+
 504+/** Portuguese (Português)
 505+ * @author Hamilton Abreu
 506+ */
 507+$messages['pt'] = array(
 508+ 'livetranslate-desc' => 'Permite a tradução imediata do conteúdo das páginas usando o serviço Google Translate',
 509+ 'livetranslate-translate-to' => 'Traduzir esta página para',
 510+ 'livetranslate-button-translate' => 'Traduzir',
 511+ 'livetranslate-button-translating' => 'A traduzir...',
 512+ 'livetranslate-button-revert' => 'Mostrar original',
 513+ '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.',
 514+ 'livetranslate-dictionary-empty' => 'Ainda não existem palavras no dicionário. Clique o separador "editar" para adicionar algumas.',
 515+ '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.',
 516+ '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.',
 517+);
 518+
 519+/** Brazilian Portuguese (Português do Brasil)
 520+ * @author Giro720
 521+ */
 522+$messages['pt-br'] = array(
 523+ 'livetranslate-desc' => 'Permite a tradução imediata do conteúdo das páginas usando o serviço Google Translate',
 524+ 'livetranslate-translate-to' => 'Traduzir esta página para',
 525+ 'livetranslate-button-translate' => 'Traduzir',
 526+ 'livetranslate-button-translating' => 'Traduzindo...',
 527+);
 528+
 529+/** Russian (Русский)
 530+ * @author Byulent
 531+ * @author MaxSem
 532+ * @author Александр Сигачёв
 533+ */
 534+$messages['ru'] = array(
 535+ 'livetranslate-desc' => 'Включает перевод текста страницы на лету с помощью службы переводов Google',
 536+ 'livetranslate-translate-to' => 'Перевести эту страницу на',
 537+ 'livetranslate-button-translate' => 'Перевести',
 538+ 'livetranslate-button-translating' => 'Выполняется перевод...',
 539+ 'livetranslate-button-revert' => 'Показать оригинал',
 540+ 'livetranslate-dictionary-error' => 'Не удалось получить словарь живого перевода. Нет слов, которые будут рассматриваться как специальные во время процесса перевода.',
 541+ 'livetranslate-dictionary-empty' => 'В словаре ещё нет слов. Нажмите «править», чтобы добавить несколько.',
 542+ 'livetranslate-dictionary-count' => '$1 {{PLURAL:$1|слово|слова|слов}} на $2 {{PLURAL:$2|языке|языках|языках}}. Нажмите «править», чтобы добавить ещё.',
 543+ 'livetranslate-dictionary-unallowed-langs' => '{{PLURAL:$2|Этот язык|Эти языки}} не разрешено использовать в качестве цели перевода: $1. Измените разрешения в настройках вашей вики, или удалите их из словаря.',
 544+ 'livetranslate-dictionary-goto-edit' => 'Изменение памяти переводов.',
 545+ 'special-livetranslate' => 'Перевод на лету',
 546+ 'livetranslate-tmtype-ltf' => 'Формат перевода на лету',
 547+ 'livetranslate-tmtype-tmx' => 'Обмен памятью перевода',
 548+ 'livetranslate-tmtype-gcsv' => 'Google CSV',
 549+ 'livetranslate-special-no-tms-yet' => 'Памяти переводов пока нет.',
 550+);
 551+
 552+/** Telugu (తెలుగు)
 553+ * @author Veeven
 554+ */
 555+$messages['te'] = array(
 556+ 'livetranslate-translate-to' => 'ఈ పుటని అనువదించండి',
 557+ 'livetranslate-button-translate' => 'అనువదించు',
 558+ 'livetranslate-button-translating' => 'అనువదిస్తున్నాం...',
 559+);
 560+
 561+/** Ukrainian (Українська)
 562+ * @author Тест
 563+ */
 564+$messages['uk'] = array(
 565+ 'livetranslate-desc' => 'Робить можливим безпосередній переклад вмісту сторінки за допомогою служби Google Translate',
 566+ 'livetranslate-translate-to' => 'Перекласти цю сторінку',
 567+ 'livetranslate-button-translate' => 'Перекласти',
 568+ 'livetranslate-button-translating' => 'Перекладаю...',
 569+ 'livetranslate-button-revert' => 'Показати оригінал',
 570+ 'livetranslate-special-button' => 'Зберегти та оновити',
 571+ 'livetranslate-special-type' => 'Тип',
 572+ 'livetranslate-special-location' => 'Розташування',
 573+ 'livetranslate-special-remove' => 'Вилучити',
 574+);
 575+
Property changes on: tags/extensions/LiveTranslate/REL_0_5/LiveTranslate.i18n.php
___________________________________________________________________
Added: svn:eol-style
1576 + native
Index: tags/extensions/LiveTranslate/REL_0_5/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.5' );
 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_5/LiveTranslate.php
___________________________________________________________________
Added: svn:eol-style
1108 + native
Index: tags/extensions/LiveTranslate/REL_0_5/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_5/LiveTranslate_Settings.php
___________________________________________________________________
Added: svn:eol-style
136 + native
Index: tags/extensions/LiveTranslate/REL_0_5/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_5/specials/SpecialLiveTranslate.php
___________________________________________________________________
Added: svn:eol-style
1369 + native
Index: tags/extensions/LiveTranslate/REL_0_5/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+ '&#160;' .
 154+ LiveTranslateFunctions::getLanguageSelector( $currentLang ) .
 155+ '&#160;' .
 156+ Html::element(
 157+ 'button',
 158+ array( 'id' => 'livetranslatebutton' ),
 159+ wfMsg( 'livetranslate-button-translate' )
 160+ ) .
 161+ '&#160;' .
 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_5/LiveTranslate.hooks.php
___________________________________________________________________
Added: svn:eol-style
1290 + native
Index: tags/extensions/LiveTranslate/REL_0_5/INSTALL
@@ -0,0 +1,47 @@
 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+You also need to run this when upgrading to version 0.4 or above from any older version.
 18+
 19+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:
 20+
 21+== Configuration ==
 22+
 23+Configuration of Live Translate is done by adding simple PHP statements to your [[Manual:LocalSettings.php|LocalSettings.php]]
 24+file. These statements need to be placed AFTER the inclusion of Live Translate. The options are listed below and their default
 25+is set in the [http://svn.wikimedia.org/viewvc/mediawiki/trunk/extensions/LiveTranslate/LiveTranslate_Settings.php?view=markup Live Translate settings file].
 26+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.
 27+
 28+=== Google API key ===
 29+
 30+To be able to actually use Google Translate, you need to [https://code.google.com/apis/console get an API key] and
 31+add it to your [[LocalSettings.php]] file AFTER the inclusion of the extension.
 32+
 33+<source lang="php">
 34+# Google API key
 35+$egGoogleApiKey = 'INSERT-YOUR-KEY-HERE';
 36+</source>
 37+
 38+=== Available languages ===
 39+
 40+You have to specify which languages users should be able to translate to. This is done by adding language codes to <code>$egLiveTranslateLanguages</code>.
 41+By default it contains only your wikis main language (as specified by <code>$wgLanguageCode</code> in [[LocalSettings.php]]). You add languages as follows:
 42+
 43+<source lang="php">
 44+$egLiveTranslateLanguages[] = 'nl';
 45+$egLiveTranslateLanguages[] = 'de';
 46+</source>
 47+
 48+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_5/RELEASE-NOTES
@@ -0,0 +1,44 @@
 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.5 ===
 9+2011-01-16
 10+
 11+* Modified the LT API to work with batches, so translation doesn't break for big translation memories.
 12+* Fixed regex escaping issue that caused translations to stop when encountering certain characters in special words.
 13+
 14+=== Version 0.4 ===
 15+2011-01-14
 16+
 17+* Added support for multiple translation memories.
 18+* Added Special:LiveTranslate to manage the translation memories that should be used.
 19+* Added support for remote translation memories.
 20+* Added support for the Translation Memory eXchange (TMX) format.
 21+* Added Google branding, which is required when using the Google Translate API.
 22+: https://code.google.com/apis/language/translate/v1/getting_started.html#getBranding
 23+* Improved translation memory insertion into the database.
 24+* Added better tracking of translation memory sizes and language counts.
 25+
 26+=== Version 0.3 ===
 27+2011-01-07
 28+
 29+* Added (partial) compatibility with IE8. Random errors still occur. Use a modern browser to prevent this.
 30+* Fixed issue with trim-prevention, causing |-signs to semi-randomly get inserted into translated text.
 31+* Only show the translation control when an API key is provided.
 32+
 33+=== Version 0.2 ===
 34+2010-12-24
 35+
 36+* Fixed installation compatibility issue with MW 1.16.
 37+* Fixed display of translation control to only happen on existing pages.
 38+* Fixed issues with inserting notranslatre tags into the page source.
 39+
 40+=== Version 0.1 ===
 41+2010-12-22
 42+
 43+* Added simple translation interface to the right top of articles.
 44+* Implemented translation via the Google Translate API.
 45+* Added dictionary for special words with synonyms support.
Index: tags/extensions/LiveTranslate/REL_0_5/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_5/includes/LT_TMParser.php
___________________________________________________________________
Added: svn:eol-style
164 + native
Index: tags/extensions/LiveTranslate/REL_0_5/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_5/includes/LT_GCSVParser.php
___________________________________________________________________
Added: svn:eol-style
126 + native
Index: tags/extensions/LiveTranslate/REL_0_5/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_5/includes/LT_TMUnit.php
___________________________________________________________________
Added: svn:eol-style
1145 + native
Index: tags/extensions/LiveTranslate/REL_0_5/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_5/includes/LT_LTFParser.php
___________________________________________________________________
Added: svn:eol-style
147 + native
Index: tags/extensions/LiveTranslate/REL_0_5/includes/ext.livetranslate.js
@@ -0,0 +1,374 @@
 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+ * Disables the translation button and then either kicks of insertion of
 49+ * notranslate spans around special words, or when this already happened,
 50+ * the actual translation process.
 51+ */
 52+ setupTranslationFeatures = function() {
 53+ $( this ).attr( "disabled", true ).text( mediaWiki.msg( 'livetranslate-button-translating' ) );
 54+
 55+ if ( originalHtml === false ) {
 56+ obtainAndInsertTranslations( -1 );
 57+ }
 58+ else {
 59+ initiateTranslating();
 60+ }
 61+ }
 62+
 63+ /**
 64+ * Queries a batch of special words in the source language, finds them in the page,
 65+ * and wraps the into notranslate spans. If there are no more words, the translation
 66+ * process is initaiated, otherwise the function calls itself again.
 67+ */
 68+ function obtainAndInsertTranslations( offset ) {
 69+ var requestArgs = {
 70+ 'action': 'query',
 71+ 'format': 'json',
 72+ 'list': 'livetranslate',
 73+ 'ltlanguage': currentLang,
 74+ };
 75+
 76+ if ( offset > 0 ) {
 77+ requestArgs['ltcontinue'] = offset;
 78+ }
 79+
 80+ $.getJSON(
 81+ wgScriptPath + '/api.php',
 82+ requestArgs,
 83+ function( data ) {
 84+ if ( data.words ) {
 85+ insertNoTranslateTags( data.words );
 86+ }
 87+ else if ( data.error && data.error.info ) {
 88+ alert( data.error.info );
 89+ }
 90+ else {
 91+ for ( i in data ) {
 92+ alert( mediaWiki.msg( 'livetranslate-dictionary-error' ) );
 93+ break;
 94+ }
 95+ }
 96+
 97+ originalHtml = $( '#bodyContent' ).html();
 98+
 99+ if ( data['query-continue'] ) {
 100+ obtainAndInsertTranslations( data['query-continue'].livetranslate.ltcontinue );
 101+ }
 102+ else {
 103+ initiateTranslating();
 104+ }
 105+ }
 106+ );
 107+ }
 108+
 109+ /**
 110+ * Initiates the translation process.
 111+ * First all special words are found and send to the local API,
 112+ * and then replaced by their translation in the response. Then
 113+ * the Google Translate translation is initiated.
 114+ */
 115+ function initiateTranslating() {
 116+ var words = getSpecialWords();
 117+ var newLang = $( '#livetranslatelang' ).val();
 118+
 119+ if ( words.length == 0 ) {
 120+ requestGoogleTranslate( currentLang, newLang );
 121+ }
 122+ else {
 123+ $.getJSON(
 124+ wgScriptPath + '/api.php',
 125+ {
 126+ 'action': 'livetranslate',
 127+ 'format': 'json',
 128+ 'from': currentLang,
 129+ 'to': newLang,
 130+ 'words': words.join( '|' )
 131+ },
 132+ function( data ) {
 133+ if ( data.translations ) {
 134+ replaceSpecialWords( data.translations );
 135+ }
 136+ requestGoogleTranslate( currentLang, newLang );
 137+ }
 138+ );
 139+ }
 140+ }
 141+
 142+ /**
 143+ * Shows the original page content, simply by setting the html to a stored copy of the original.
 144+ * Also re-binds the jQuery events, as they get lost when doing the html replace.
 145+ */
 146+ showOriginal = function() {
 147+ currentLang = window.sourceLang;
 148+ $( '#bodyContent' ).html( originalHtml );
 149+ $( '#livetranslatebutton' ).attr( "disabled", false ).text( mediaWiki.msg( 'livetranslate-button-translate' ) );
 150+ $( '#livetranslatebutton' ).click( setupTranslationFeatures );
 151+ $( '#ltrevertbutton' ).click( showOriginal );
 152+ }
 153+
 154+ // Initial binding of the button click events.
 155+ $( '#livetranslatebutton' ).click( setupTranslationFeatures );
 156+ $( '#ltrevertbutton' ).click( showOriginal );
 157+
 158+ /**
 159+ * Regex text escaping function.
 160+ * Borrowed from http://simonwillison.net/2006/Jan/20/escape/
 161+ */
 162+ RegExp.escape = function(text) {
 163+ if (!arguments.callee.sRE) {
 164+ var specials = [ '/', '.', '*', '+', '?', '|', '(', ')', '[', ']', '{', '}', '\\' ];
 165+ arguments.callee.sRE = new RegExp( '(\\' + specials.join('|\\') + ')', 'g' );
 166+ }
 167+ return text.replace(arguments.callee.sRE, '\\$1');
 168+ }
 169+
 170+ /**
 171+ * Inserts notranslate spans around the words specified in the passed array in the page content.
 172+ *
 173+ * @param {Array} words
 174+ */
 175+ function insertNoTranslateTags( words ) {
 176+ for ( i in words ) {
 177+ $( '#bodyContent *' ).replaceText(
 178+ new RegExp( "(\\W)*" + RegExp.escape( words[i] ) + "(\\W)*", "g" ),
 179+ function( str ) {
 180+ return '<span class="notranslate">' + str + '</span>'
 181+ }
 182+ );
 183+ }
 184+ }
 185+
 186+ /**
 187+ * Finds the special words in the page contents by getting the contents of all
 188+ * notranslate spans and pushing them onto an array.
 189+ *
 190+ * @returns {Array}
 191+ */
 192+ function getSpecialWords() {
 193+ var words = [];
 194+
 195+ $.each($( 'span.notranslate' ), function( i, v ) {
 196+ words.push( $(v).text() );
 197+ });
 198+
 199+ return words;
 200+ }
 201+
 202+ /**
 203+ * Replaced the special words in the page content by looping over them,
 204+ * and checking if there is a matching translation in the provided object.
 205+ *
 206+ * @param {object} translations
 207+ */
 208+ function replaceSpecialWords( translations ) {
 209+ $.each($("span.notranslate"), function(i,v) {
 210+ var currentText = $(v).text();
 211+ if ( translations[currentText] ) {
 212+ $(v).text( translations[currentText] );
 213+ }
 214+ });
 215+ }
 216+
 217+ /**
 218+ * Initiates the Google Translate translation.
 219+ *
 220+ * @param {string} sourceLang
 221+ * @param {string} targetLang
 222+ */
 223+ function requestGoogleTranslate( sourceLang, targetLang ) {
 224+ translateElement( $( '#bodyContent' ), sourceLang, targetLang );
 225+ }
 226+
 227+ /**
 228+ * Translates a single DOM element using Google Translate.
 229+ * Loops through child elements and recursivly calls itself to translate these.
 230+ *
 231+ * TODO: be smarter with the requests, and make sure they don't get broken up unecesarrily.
 232+ *
 233+ * @param {jQuery} element
 234+ * @param {string} sourceLang
 235+ * @param {string} targetLang
 236+ */
 237+ function translateElement( element, sourceLang, targetLang ) {
 238+ runningJobs++;
 239+
 240+ var maxChunkLength = 500;
 241+
 242+ element.contents().each( function() {
 243+ // If it's a text node, then translate it.
 244+ if ( this.nodeType == 3 && this.data != undefined && jQuery.trim( this.data ).length > 0 ) {
 245+ runningJobs++;
 246+ translateChunk(
 247+ this.data.split( new RegExp( "(\\S.+?[.!?])(?=\\s+|$)", "gi" ) ),
 248+ [],
 249+ maxChunkLength,
 250+ sourceLang,
 251+ targetLang,
 252+ this
 253+ );
 254+ }
 255+ // If it's an html element, check to see if it should be ignored, and if not, apply function again.
 256+ else if ( $.inArray( $( this ).attr( 'id' ), [ 'siteSub', 'jump-to-nav' ] ) == -1
 257+ && !$( this ).hasClass( 'notranslate' ) && !$( this ).hasClass( 'printfooter' )
 258+ && $( this ).text().length > 0 ) {
 259+
 260+ translateElement( $( this ), sourceLang, targetLang );
 261+ }
 262+ } );
 263+
 264+ handleTranslationCompletion( targetLang );
 265+ }
 266+
 267+ /**
 268+ * Determines a chunk to translate of an DOM elements contents and calls the Google Translate API.
 269+ * Then calls itself if there is any remaining work to be done.
 270+ *
 271+ * @param {array} untranslatedsentences
 272+ * @param {array} chunks
 273+ * @param {integer} currentMaxSize
 274+ * @param {string} sourceLang
 275+ * @param {string} targetLang
 276+ * @param {jQuery} element
 277+ */
 278+ function translateChunk( untranslatedsentences, chunks, currentMaxSize, sourceLang, targetLang, element ) {
 279+ var remainingPart = false;
 280+ var partToUse = false;
 281+ var sentenceCount = 0;
 282+ var currentLength = 0;
 283+
 284+ // Find the scentances that can be put in the current chunk.
 285+ for ( i in untranslatedsentences ) {
 286+ sentenceCount++;
 287+
 288+ if ( currentLength + untranslatedsentences[i].length < currentMaxSize ) {
 289+ currentLength += untranslatedsentences[i].length;
 290+ }
 291+ else if ( untranslatedsentences[i].length > 0 ) {
 292+ if ( currentLength == 0 ) {
 293+ // If the first scentance is longer then the max chunk legth, split it.
 294+ partToUse = untranslatedsentences[i].substr( 0, currentMaxSize - currentLength );
 295+ remainingPart = untranslatedsentences[i].substr( currentMaxSize - currentLength );
 296+ }
 297+
 298+ break;
 299+ }
 300+ }
 301+
 302+ var chunk = '';
 303+
 304+ // Build the chunck.
 305+ for ( i = 0; i < sentenceCount; i++ ) {
 306+ var part = untranslatedsentences.shift();
 307+
 308+ if ( i != sentenceCount - 1 || partToUse === false ) {
 309+ chunk += part;
 310+ }
 311+ }
 312+
 313+ // If there is a remaining part, re-add it to the scentances to translate list.
 314+ if ( remainingPart !== false ) {
 315+ untranslatedsentences.unshift( remainingPart );
 316+ }
 317+
 318+ // If there is a partial scentance, add it to the chunk.
 319+ if ( partToUse !== false ) {
 320+ chunk += partToUse;
 321+ }
 322+
 323+ // If the lenght is 0, the element has been translated.
 324+ if ( chunk.length == 0 ) {
 325+ handleTranslationCompletion( targetLang );
 326+ return;
 327+ }
 328+
 329+ // Keep track of leading and tailing spaces, as they often get modified by the GT API.
 330+ var leadingSpace = chunk.substr( 0, 1 ) == ' ' ? ' ' : '';
 331+ var tailingSpace = ( chunk.length > 1 && chunk.substr( chunk.length - 1, 1 ) == ' ' ) ? ' ' : '';
 332+
 333+ google.language.translate(
 334+ jQuery.trim( chunk ), // Trim, so the result does not contain preceding or tailing spaces.
 335+ sourceLang,
 336+ targetLang,
 337+ function(result) {
 338+ if ( result.translation ) {
 339+ chunks.push( leadingSpace + result.translation + tailingSpace );
 340+ }
 341+ else {
 342+ // If the translation failed, keep the original text.
 343+ chunks.push( chunk );
 344+ }
 345+
 346+ if ( untranslatedsentences.length == 0 ) {
 347+ // If the current chunk was smaller then the max size, node translation is complete, so update text.
 348+ textAreaElement.innerHTML = chunks.join(); // This is a hack to decode quotes.
 349+ element.replaceData( 0, element.length, textAreaElement.value );
 350+ handleTranslationCompletion( targetLang );
 351+ }
 352+ else {
 353+ // If there is more work to do, move on to the next chunk.
 354+ translateChunk( untranslatedsentences, chunks, currentMaxSize, sourceLang, targetLang, element );
 355+ }
 356+ }
 357+ );
 358+ }
 359+
 360+ /**
 361+ * Should be called every time a DOM element has been translated.
 362+ * By use of the runningJobs var, completion of the translation process is detected,
 363+ * and further handled by this function.
 364+ *
 365+ * @param {string} targetLang
 366+ */
 367+ function handleTranslationCompletion( targetLang ) {
 368+ if ( !--runningJobs ) {
 369+ currentLang = targetLang;
 370+ $( '#livetranslatebutton' ).attr( "disabled", false ).text( mediaWiki.msg( 'livetranslate-button-translate' ) );
 371+ $( '#ltrevertbutton' ).css( 'display', 'inline' );
 372+ }
 373+ }
 374+
 375+} ); })(jQuery);
\ No newline at end of file
Property changes on: tags/extensions/LiveTranslate/REL_0_5/includes/ext.livetranslate.js
___________________________________________________________________
Added: svn:eol-style
1376 + native
Index: tags/extensions/LiveTranslate/REL_0_5/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_5/includes/LT_TMXParser.php
___________________________________________________________________
Added: svn:eol-style
1197 + native
Index: tags/extensions/LiveTranslate/REL_0_5/includes/LiveTranslate_Functions.php
@@ -0,0 +1,374 @@
 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+ * Returns a PHP version of the JavaScript google.language.Languages enum of the Google Translate v1 API.
 148+ * @see https://code.google.com/apis/language/translate/v1/getting_started.html#LangNameArray
 149+ *
 150+ * @since 0.1
 151+ *
 152+ * @return array LANGUAGE_NAME => 'code'
 153+ */
 154+ public static function getGTSupportedLanguages() { //Language::getLanguageNames( false );
 155+ return array(
 156+ 'AFRIKAANS' => 'af',
 157+ 'ALBANIAN' => 'sq',
 158+ 'AMHARIC' => 'am',
 159+ 'ARABIC' => 'ar',
 160+ 'ARMENIAN' => 'hy',
 161+ 'AZERBAIJANI' => 'az',
 162+ 'BASQUE' => 'eu',
 163+ 'BELARUSIAN' => 'be',
 164+ 'BENGALI' => 'bn',
 165+ 'BIHARI' => 'bh',
 166+ 'BRETON' => 'br',
 167+ 'BULGARIAN' => 'bg',
 168+ 'BURMESE' => 'my',
 169+ 'CATALAN' => 'ca',
 170+ 'CHEROKEE' => 'chr',
 171+ 'CHINESE' => 'zh',
 172+ 'CHINESE_SIMPLIFIED' => 'zh-CN',
 173+ 'CHINESE_TRADITIONAL' => 'zh-TW',
 174+ 'CORSICAN' => 'co',
 175+ 'CROATIAN' => 'hr',
 176+ 'CZECH' => 'cs',
 177+ 'DANISH' => 'da',
 178+ 'DHIVEHI' => 'dv',
 179+ 'DUTCH'=> 'nl',
 180+ 'ENGLISH' => 'en',
 181+ 'ESPERANTO' => 'eo',
 182+ 'ESTONIAN' => 'et',
 183+ 'FAROESE' => 'fo',
 184+ 'FILIPINO' => 'tl',
 185+ 'FINNISH' => 'fi',
 186+ 'FRENCH' => 'fr',
 187+ 'FRISIAN' => 'fy',
 188+ 'GALICIAN' => 'gl',
 189+ 'GEORGIAN' => 'ka',
 190+ 'GERMAN' => 'de',
 191+ 'GREEK' => 'el',
 192+ 'GUJARATI' => 'gu',
 193+ 'HAITIAN_CREOLE' => 'ht',
 194+ 'HEBREW' => 'iw',
 195+ 'HINDI' => 'hi',
 196+ 'HUNGARIAN' => 'hu',
 197+ 'ICELANDIC' => 'is',
 198+ 'INDONESIAN' => 'id',
 199+ 'INUKTITUT' => 'iu',
 200+ 'IRISH' => 'ga',
 201+ 'ITALIAN' => 'it',
 202+ 'JAPANESE' => 'ja',
 203+ 'JAVANESE' => 'jw',
 204+ 'KANNADA' => 'kn',
 205+ 'KAZAKH' => 'kk',
 206+ 'KHMER' => 'km',
 207+ 'KOREAN' => 'ko',
 208+ 'KURDISH'=> 'ku',
 209+ 'KYRGYZ'=> 'ky',
 210+ 'LAO' => 'lo',
 211+ 'LATIN' => 'la',
 212+ 'LATVIAN' => 'lv',
 213+ 'LITHUANIAN' => 'lt',
 214+ 'LUXEMBOURGISH' => 'lb',
 215+ 'MACEDONIAN' => 'mk',
 216+ 'MALAY' => 'ms',
 217+ 'MALAYALAM' => 'ml',
 218+ 'MALTESE' => 'mt',
 219+ 'MAORI' => 'mi',
 220+ 'MARATHI' => 'mr',
 221+ 'MONGOLIAN' => 'mn',
 222+ 'NEPALI' => 'ne',
 223+ 'NORWEGIAN' => 'no',
 224+ 'OCCITAN' => 'oc',
 225+ 'ORIYA' => 'or',
 226+ 'PASHTO' => 'ps',
 227+ 'PERSIAN' => 'fa',
 228+ 'POLISH' => 'pl',
 229+ 'PORTUGUESE' => 'pt',
 230+ 'PORTUGUESE_PORTUGAL' => 'pt-PT',
 231+ 'PUNJABI' => 'pa',
 232+ 'QUECHUA' => 'qu',
 233+ 'ROMANIAN' => 'ro',
 234+ 'RUSSIAN' => 'ru',
 235+ 'SANSKRIT' => 'sa',
 236+ 'SCOTS_GAELIC' => 'gd',
 237+ 'SERBIAN' => 'sr',
 238+ 'SINDHI' => 'sd',
 239+ 'SINHALESE' => 'si',
 240+ 'SLOVAK' => 'sk',
 241+ 'SLOVENIAN' => 'sl',
 242+ 'SPANISH' => 'es',
 243+ 'SUNDANESE' => 'su',
 244+ 'SWAHILI' => 'sw',
 245+ 'SWEDISH' => 'sv',
 246+ 'SYRIAC' => 'syr',
 247+ 'TAJIK' => 'tg',
 248+ 'TAMIL' => 'ta',
 249+ 'TATAR' => 'tt',
 250+ 'TELUGU' => 'te',
 251+ 'THAI' => 'th',
 252+ 'TIBETAN' => 'bo',
 253+ 'TONGA' => 'to',
 254+ 'TURKISH' => 'tr',
 255+ 'UKRAINIAN' => 'uk',
 256+ 'URDU' => 'ur',
 257+ 'UZBEK' => 'uz',
 258+ 'UIGHUR' => 'ug',
 259+ 'VIETNAMESE' => 'vi',
 260+ 'WELSH' => 'cy',
 261+ 'YIDDISH' => 'yi',
 262+ 'YORUBA' => 'yo',
 263+ );
 264+ }
 265+
 266+ /**
 267+ * Returns an array with mapping from input language codes to MediaWiki language codes.
 268+ *
 269+ * @since 0.4
 270+ *
 271+ * @return array
 272+ */
 273+ public static function getInputLangMapping() {
 274+ return array(
 275+ 'en-us' => 'en',
 276+ );
 277+ }
 278+
 279+ /**
 280+ * Returns an array with mapping from MediaWiki language codes to Google Translate language codes.
 281+ *
 282+ * @since 0.4
 283+ *
 284+ * @return array
 285+ */
 286+ public static function getOuputLangMapping() {
 287+ return array(
 288+ 'en-us' => 'en',
 289+ 'en-gb' => 'en',
 290+ );
 291+ }
 292+
 293+ /**
 294+ * Returns the provided text starting with a letter in toggeled case.
 295+ * If there is no difference between lowercase and upercase for the first
 296+ * character, false is returned.
 297+ *
 298+ * @since 0.1
 299+ *
 300+ * @param string $text
 301+ *
 302+ * @return mixed
 303+ */
 304+ public static function getToggledCase( $text ) {
 305+ $isUpper = Language::firstChar( $text) == strtoupper( Language::firstChar( $text) );
 306+ $isLower = Language::firstChar( $text) == strtolower( Language::firstChar( $text) );
 307+
 308+ if ( $isUpper XOR $isLower ) {
 309+ $text = $isUpper ? Language::lcfirst( $text ) : Language::ucfirst( $text );
 310+ return $text;
 311+ }
 312+ else {
 313+ return false;
 314+ }
 315+ }
 316+
 317+ /**
 318+ * Returns the names of the pages containing a translation memory.
 319+ *
 320+ * @since 0.4
 321+ *
 322+ * @return array
 323+ */
 324+ public static function getLocalMemoryNames() {
 325+ $dbr = wfGetDb( DB_MASTER );
 326+
 327+ $res = $dbr->select(
 328+ 'live_translate_memories',
 329+ array( 'memory_location' ),
 330+ array( 'memory_local' => 1 ),
 331+ __METHOD__,
 332+ array( 'LIMIT' => '5000' )
 333+ );
 334+
 335+ $names = array();
 336+
 337+ foreach ( $res as $tm ) {
 338+ $names[] = $tm->memory_location;
 339+ }
 340+
 341+ return $names;
 342+ }
 343+
 344+ /**
 345+ * Returns the type of a translation memory when given it's location.
 346+ * If the memory is not found, -1 is returned.
 347+ *
 348+ * @since 0.4
 349+ *
 350+ * @param string $location
 351+ *
 352+ * @return integer
 353+ */
 354+ public static function getMemoryType( $location ) {
 355+ $dbr = wfGetDb( DB_MASTER );
 356+
 357+ $res = $dbr->select(
 358+ 'live_translate_memories',
 359+ array( 'memory_type' ),
 360+ array( 'memory_location' => $location ),
 361+ __METHOD__,
 362+ array( 'LIMIT' => '5000' )
 363+ );
 364+
 365+ $type = -1;
 366+
 367+ foreach ( $res as $row ) {
 368+ $type = $row->memory_type;
 369+ break;
 370+ }
 371+
 372+ return $type;
 373+ }
 374+
 375+}
\ No newline at end of file
Property changes on: tags/extensions/LiveTranslate/REL_0_5/includes/LiveTranslate_Functions.php
___________________________________________________________________
Added: svn:eol-style
1376 + native
Index: tags/extensions/LiveTranslate/REL_0_5/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_5/includes/LT_TranslationMemory.php
___________________________________________________________________
Added: svn:eol-style
178 + native
Index: tags/extensions/LiveTranslate/REL_0_5/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_5/api/ApiQueryLiveTranslate.php
@@ -0,0 +1,147 @@
 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+ $this->addTables( 'live_translate' );
 31+
 32+ $this->addFields( array(
 33+ 'word_id',
 34+ 'word_translation'
 35+ ) );
 36+
 37+ $this->addWhere( array(
 38+ 'word_language' => $params['language']
 39+ ) );
 40+
 41+ if ( !is_null( $params['continue'] ) ) {
 42+ $dbr = wfGetDB( DB_SLAVE );
 43+ $this->addWhere( 'word_id >= ' . $dbr->addQuotes( $params['continue'] ) );
 44+ }
 45+
 46+ $this->addOption( 'LIMIT', $params['limit'] + 1 );
 47+ $this->addOption( 'ORDER BY', 'word_id ASC' );
 48+
 49+ $words = $this->select( __METHOD__ );
 50+ $specialWords = array();
 51+ $count = 0;
 52+
 53+ while ( $word = $words->fetchObject() ) {
 54+ if ( ++$count > $params['limit'] ) {
 55+ // We've reached the one extra which shows that
 56+ // there are additional pages to be had. Stop here...
 57+ $this->setContinueEnumParameter( 'continue', $word->word_id );
 58+ break;
 59+ }
 60+
 61+ $specialWords[] = $word->word_translation;
 62+ }
 63+
 64+ $toggeledSpecials = array();
 65+
 66+ foreach ( $specialWords as $word ) {
 67+ $toggledWord = LiveTranslateFunctions::getToggledCase( $word );
 68+
 69+ if ( $toggledWord ) {
 70+ $toggeledSpecials[] = $toggledWord;
 71+ }
 72+ }
 73+
 74+ foreach ( array_unique( array_merge( $specialWords, $toggeledSpecials ) ) as $word ) {
 75+ $this->getResult()->addValue(
 76+ 'words',
 77+ null,
 78+ $word
 79+ );
 80+ }
 81+ }
 82+
 83+ /**
 84+ * (non-PHPdoc)
 85+ * @see includes/api/ApiBase#getAllowedParams()
 86+ */
 87+ public function getAllowedParams() {
 88+ return array (
 89+ 'language' => array(
 90+ ApiBase::PARAM_TYPE => 'string',
 91+ //ApiBase::PARAM_REQUIRED => true,
 92+ ),
 93+ 'limit' => array(
 94+ ApiBase :: PARAM_DFLT => 500,
 95+ ApiBase :: PARAM_TYPE => 'limit',
 96+ ApiBase :: PARAM_MIN => 1,
 97+ ApiBase :: PARAM_MAX => ApiBase :: LIMIT_BIG1,
 98+ ApiBase :: PARAM_MAX2 => ApiBase :: LIMIT_BIG2
 99+ ),
 100+ 'continue' => null,
 101+ );
 102+ }
 103+
 104+ /**
 105+ * (non-PHPdoc)
 106+ * @see includes/api/ApiBase#getParamDescription()
 107+ */
 108+ public function getParamDescription() {
 109+ return array (
 110+ 'language' => 'The language for which to return special words',
 111+ 'continue' => 'Offset number from where to continue the query',
 112+ 'limit' => 'Max amount of words to return',
 113+ );
 114+ }
 115+
 116+ /**
 117+ * (non-PHPdoc)
 118+ * @see includes/api/ApiBase#getDescription()
 119+ */
 120+ public function getDescription() {
 121+ return 'This module returns all special words defined in the wikis Live Translate Dictionary for a given language';
 122+ }
 123+
 124+ /**
 125+ * (non-PHPdoc)
 126+ * @see includes/api/ApiBase#getPossibleErrors()
 127+ */
 128+ public function getPossibleErrors() {
 129+ return array_merge( parent::getPossibleErrors(), array(
 130+ array( 'missingparam', 'language' ),
 131+ ) );
 132+ }
 133+
 134+ /**
 135+ * (non-PHPdoc)
 136+ * @see includes/api/ApiBase#getExamples()
 137+ */
 138+ protected function getExamples() {
 139+ return array (
 140+ 'api.php?action=query&list=livetranslate&ltlanguage',
 141+ );
 142+ }
 143+
 144+ public function getVersion() {
 145+ return __CLASS__ . ': $Id: ApiQueryLiveTranslate.php 80360 2011-01-15 00:01:29Z jeroendedauw $';
 146+ }
 147+
 148+}
Property changes on: tags/extensions/LiveTranslate/REL_0_5/api/ApiQueryLiveTranslate.php
___________________________________________________________________
Added: svn:eol-style
1149 + native
Index: tags/extensions/LiveTranslate/REL_0_5/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_5/api/ApiImportTranslationMemories.php
___________________________________________________________________
Added: svn:eol-style
1199 + native
Index: tags/extensions/LiveTranslate/REL_0_5/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 80360 2011-01-15 00:01:29Z jeroendedauw $';
 137+ }
 138+
 139+}
Property changes on: tags/extensions/LiveTranslate/REL_0_5/api/ApiLiveTranslate.php
___________________________________________________________________
Added: svn:eol-style
1140 + native
Index: tags/extensions/LiveTranslate/REL_0_5/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_5/LiveTranslate.sql
___________________________________________________________________
Added: svn:eol-style
124 + native
Index: tags/extensions/LiveTranslate/REL_0_5/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".

Status & tagging log