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

Revision: 68368
Author:   roberthl
Date:     2010-06-21 17:34:18 +0000 (Mon, 21 Jun 2010)

Log Message:
-----------
Translate: Initial work on making the OpenLayers ffs work for other projects, 
doesn't work yet but doesn't break old functionality either.

Modified Paths:
--------------
    trunk/extensions/Translate/ffs/OpenLayers.php

Modified: trunk/extensions/Translate/ffs/OpenLayers.php
===================================================================
--- trunk/extensions/Translate/ffs/OpenLayers.php       2010-06-21 17:12:48 UTC 
(rev 68367)
+++ trunk/extensions/Translate/ffs/OpenLayers.php       2010-06-21 17:34:18 UTC 
(rev 68368)
@@ -8,6 +8,8 @@
  */
 
 class OpenLayersFormatReader extends SimpleFormatReader {
+       protected $keyquote = true;
+
        private static function unescapeJsString( $string ) {
                // See ECMA 262 section 7.8.4 for string literal format
                $pairs = array(
@@ -81,7 +83,11 @@
                        $segment = implode( $segment );
                        # $segment = preg_replace( '#\" \+(.*?)\"#m', '', 
$segment );
                        // Break in to key and message.
-                       $segments = explode( '\':', $segment );
+                       if( $this->keyquote) {
+                               $segments = explode( '\':', $segment );
+                       } else {
+                               $segments = explode( ': ', $segment );
+                       }
                        $key = $segments[ 0 ];
                        unset( $segments[ 0 ] );
                        $value = implode( $segments );
@@ -89,7 +95,9 @@
                        $key = trim( $key );
                        $value = trim( $value );
                        // Remove quotation marks and syntax.
-                       $key = substr( $key, 1 );
+                       if( $this->keyquote ) {
+                               $key = substr( $key, 1 );
+                       }
                        $value = substr( $value, 1, -1 );
                        $messages[ $key ] = self::unescapeJsString( $value );
                }
@@ -151,7 +159,11 @@
                foreach ( $collection as $message ) {
                        $key = Xml::escapeJsString( $message->key() );
                        $value = Xml::escapeJsString( $message->translation() );
-                       $lines .= "    '{$message->key()}': \"{$value}\",\n\n";
+                       if( $this->keyquote ) {
+                               $lines .= "    '{$message->key()}': 
\"{$value}\",\n\n";
+                       } else {
+                               $lines .= "    {$message->key()}: 
\"{$value}\",\n\n";
+                       }
                }
 
 



_______________________________________________
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to