http://www.mediawiki.org/wiki/Special:Code/MediaWiki/89827

Revision: 89827
Author:   jeroendedauw
Date:     2011-06-10 15:37:09 +0000 (Fri, 10 Jun 2011)
Log Message:
-----------
added support for comments in the LTF

Modified Paths:
--------------
    trunk/extensions/LiveTranslate/api/ApiImportTranslationMemories.php
    trunk/extensions/LiveTranslate/includes/LT_LTFParser.php

Modified: trunk/extensions/LiveTranslate/api/ApiImportTranslationMemories.php
===================================================================
--- trunk/extensions/LiveTranslate/api/ApiImportTranslationMemories.php 
2011-06-10 15:35:24 UTC (rev 89826)
+++ trunk/extensions/LiveTranslate/api/ApiImportTranslationMemories.php 
2011-06-10 15:37:09 UTC (rev 89827)
@@ -47,7 +47,7 @@
                        );                      
                        
                        foreach ( $res as $tm ) {
-                               if ( $tm->memory_local != "0" ) {
+                               if ( $tm->memory_local != '0' ) {
                                        // Obtain the contents of the article.
                                        $title = Title::newFromText( $location, 
NS_MAIN );
                                        

Modified: trunk/extensions/LiveTranslate/includes/LT_LTFParser.php
===================================================================
--- trunk/extensions/LiveTranslate/includes/LT_LTFParser.php    2011-06-10 
15:35:24 UTC (rev 89826)
+++ trunk/extensions/LiveTranslate/includes/LT_LTFParser.php    2011-06-10 
15:37:09 UTC (rev 89827)
@@ -22,10 +22,24 @@
                
                $translationSets = array();
                
+               $text = preg_replace( '/\\<!--([^(--\\>)]*)--\\>/', '', $text );
                $lines = explode( "\n", $text );
-               $languages = array_map( 'trim', explode( ',', array_shift( 
$lines ) ) );
                
+               while ( true ) {
+                       $languages = array_shift( $lines );
+                       
+                       if ( trim( $languages ) != '' ) {
+                               break;
+                       }
+               }
+               
+               $languages = array_map( 'trim', explode( ',', $languages ) );
+               
                foreach ( $lines as $line ) {
+                       if ( trim( $line ) == '' ) {
+                               continue;
+                       }
+                       
                        $values = array_map( 'trim', explode( ',', $line ) );
                        $tu = new LTTMUnit();
                        


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to