r79899 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r79898‎ | r79899 | r79900 >
Date:15:53, 9 January 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Adding more translation memory format independent parsing so suppoprt for TMX and the Google CSV format can be added. Also updated release notes and added new settings
Modified paths:
  • /trunk/extensions/LiveTranslate/LiveTranslate.php (modified) (history)
  • /trunk/extensions/LiveTranslate/LiveTranslate_Settings.php (modified) (history)
  • /trunk/extensions/LiveTranslate/RELEASE-NOTES (modified) (history)
  • /trunk/extensions/LiveTranslate/includes/LT_TMParser.php (added) (history)
  • /trunk/extensions/LiveTranslate/includes/LT_TMUnit.php (added) (history)
  • /trunk/extensions/LiveTranslate/includes/LT_TMXParser.php (added) (history)
  • /trunk/extensions/LiveTranslate/includes/LT_TranslationMemory.php (added) (history)

Diff [purge]

Index: trunk/extensions/LiveTranslate/LiveTranslate.php
@@ -48,8 +48,15 @@
4949 $wgAutoloadClasses['LiveTranslateHooks'] = $egLiveTranslateIP . '/LiveTranslate.hooks.php';
5050 $wgAutoloadClasses['ApiLiveTranslate'] = $egLiveTranslateIP . '/api/ApiLiveTranslate.php';
5151 $wgAutoloadClasses['ApiQueryLiveTranslate'] = $egLiveTranslateIP . '/api/ApiQueryLiveTranslate.php';
52 -$wgAutoloadClasses['LiveTranslateFunctions'] = $egLiveTranslateIP . '/includes/LiveTranslate_Functions.php';
5352
 53+$incDirIP = $egLiveTranslateIP . '/includes/';
 54+$wgAutoloadClasses['LiveTranslateFunctions'] = $incDirIP . 'LiveTranslate_Functions.php';
 55+$wgAutoloadClasses['LTTMParser'] = $incDirIP . 'LT_TMParser.php';
 56+$wgAutoloadClasses['LTTMUnit'] = $incDirIP . 'LT_TMUnit.php';
 57+$wgAutoloadClasses['LTTMXParser'] = $incDirIP . 'LT_TMXParser.php';
 58+$wgAutoloadClasses['LTTranslationMemory'] = $incDirIP . 'LT_TranslationMemory.php';
 59+unset( $incDirIP );
 60+
5461 $wgAPIModules['livetranslate'] = 'ApiLiveTranslate';
5562 $wgAPIListModules['livetranslate'] = 'ApiQueryLiveTranslate';
5663
Index: trunk/extensions/LiveTranslate/LiveTranslate_Settings.php
@@ -28,3 +28,13 @@
2929 $egLiveTranslateLanguages = array(
3030 $wgLanguageCode,
3131 );
 32+
 33+# A list of translation memory exchange (TMX) files.
 34+$egLiveTranslateTXMFiles = array(
 35+
 36+);
 37+
 38+# A list of translation memory files in the Google CSV format.
 39+$egLiveTranslateGCVSFiles = array(
 40+
 41+);
Index: trunk/extensions/LiveTranslate/RELEASE-NOTES
@@ -7,13 +7,15 @@
88 === Version 0.4 ===
99 2011-01-xx
1010
 11+* Added support for Translation Memory eXchange (TMX) files.
 12+* Added support for translation memory files in the Google CSV format.
1113 * Added Google branding, which is required when using the Google Translate API.
1214 : https://code.google.com/apis/language/translate/v1/getting_started.html#getBranding
1315
1416 === Version 0.3 ===
1517 2011-01-07
1618
17 -* Added compatibility with IE8.
 19+* Added (partial) compatibility with IE8. Random errors still occur. Use a modern browser to prevent this.
1820 * Fixed issue with trim-prevention, causing |-signs to semi-randomly get inserted into translated text.
1921 * Only show the translation control when an API key is provided.
2022
Index: trunk/extensions/LiveTranslate/includes/LT_TMParser.php
@@ -0,0 +1,36 @@
 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+}
Property changes on: trunk/extensions/LiveTranslate/includes/LT_TMParser.php
___________________________________________________________________
Added: svn:eol-style
138 + native
Index: trunk/extensions/LiveTranslate/includes/LT_TMUnit.php
@@ -0,0 +1,77 @@
 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+}
Property changes on: trunk/extensions/LiveTranslate/includes/LT_TMUnit.php
___________________________________________________________________
Added: svn:eol-style
179 + native
Index: trunk/extensions/LiveTranslate/includes/LT_TMXParser.php
@@ -0,0 +1,24 @@
 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+ */
 15+class LTTMXParser extends LTTMParser {
 16+
 17+ /**
 18+ * (non-PHPdoc)
 19+ * @see LTTMParser::parse()
 20+ */
 21+ public function parse( $text ) {
 22+
 23+ }
 24+
 25+}
Property changes on: trunk/extensions/LiveTranslate/includes/LT_TMXParser.php
___________________________________________________________________
Added: svn:eol-style
126 + native
Index: trunk/extensions/LiveTranslate/includes/LT_TranslationMemory.php
@@ -0,0 +1,54 @@
 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+ $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+}
Property changes on: trunk/extensions/LiveTranslate/includes/LT_TranslationMemory.php
___________________________________________________________________
Added: svn:eol-style
156 + native

Status & tagging log