Index: trunk/extensions/LiveTranslate/LiveTranslate.php |
— | — | @@ -48,8 +48,15 @@ |
49 | 49 | $wgAutoloadClasses['LiveTranslateHooks'] = $egLiveTranslateIP . '/LiveTranslate.hooks.php'; |
50 | 50 | $wgAutoloadClasses['ApiLiveTranslate'] = $egLiveTranslateIP . '/api/ApiLiveTranslate.php'; |
51 | 51 | $wgAutoloadClasses['ApiQueryLiveTranslate'] = $egLiveTranslateIP . '/api/ApiQueryLiveTranslate.php'; |
52 | | -$wgAutoloadClasses['LiveTranslateFunctions'] = $egLiveTranslateIP . '/includes/LiveTranslate_Functions.php'; |
53 | 52 | |
| 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 | + |
54 | 61 | $wgAPIModules['livetranslate'] = 'ApiLiveTranslate'; |
55 | 62 | $wgAPIListModules['livetranslate'] = 'ApiQueryLiveTranslate'; |
56 | 63 | |
Index: trunk/extensions/LiveTranslate/LiveTranslate_Settings.php |
— | — | @@ -28,3 +28,13 @@ |
29 | 29 | $egLiveTranslateLanguages = array( |
30 | 30 | $wgLanguageCode, |
31 | 31 | ); |
| 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 @@ |
8 | 8 | === Version 0.4 === |
9 | 9 | 2011-01-xx |
10 | 10 | |
| 11 | +* Added support for Translation Memory eXchange (TMX) files. |
| 12 | +* Added support for translation memory files in the Google CSV format. |
11 | 13 | * Added Google branding, which is required when using the Google Translate API. |
12 | 14 | : https://code.google.com/apis/language/translate/v1/getting_started.html#getBranding |
13 | 15 | |
14 | 16 | === Version 0.3 === |
15 | 17 | 2011-01-07 |
16 | 18 | |
17 | | -* Added compatibility with IE8. |
| 19 | +* Added (partial) compatibility with IE8. Random errors still occur. Use a modern browser to prevent this. |
18 | 20 | * Fixed issue with trim-prevention, causing |-signs to semi-randomly get inserted into translated text. |
19 | 21 | * Only show the translation control when an API key is provided. |
20 | 22 | |
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 |
1 | 38 | + 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 |
1 | 79 | + 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 |
1 | 26 | + 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 |
1 | 56 | + native |