r68368 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r68367‎ | r68368 | r68369 >
Date:17:34, 21 June 2010
Author:roberthl
Status:deferred
Tags:
Comment:
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) (history)

Diff [purge]

Index: trunk/extensions/Translate/ffs/OpenLayers.php
@@ -8,6 +8,8 @@
99 */
1010
1111 class OpenLayersFormatReader extends SimpleFormatReader {
 12+ protected $keyquote = true;
 13+
1214 private static function unescapeJsString( $string ) {
1315 // See ECMA 262 section 7.8.4 for string literal format
1416 $pairs = array(
@@ -81,7 +83,11 @@
8284 $segment = implode( $segment );
8385 # $segment = preg_replace( '#\" \+(.*?)\"#m', '', $segment );
8486 // Break in to key and message.
85 - $segments = explode( '\':', $segment );
 87+ if( $this->keyquote) {
 88+ $segments = explode( '\':', $segment );
 89+ } else {
 90+ $segments = explode( ': ', $segment );
 91+ }
8692 $key = $segments[ 0 ];
8793 unset( $segments[ 0 ] );
8894 $value = implode( $segments );
@@ -89,7 +95,9 @@
9096 $key = trim( $key );
9197 $value = trim( $value );
9298 // Remove quotation marks and syntax.
93 - $key = substr( $key, 1 );
 99+ if( $this->keyquote ) {
 100+ $key = substr( $key, 1 );
 101+ }
94102 $value = substr( $value, 1, -1 );
95103 $messages[ $key ] = self::unescapeJsString( $value );
96104 }
@@ -151,7 +159,11 @@
152160 foreach ( $collection as $message ) {
153161 $key = Xml::escapeJsString( $message->key() );
154162 $value = Xml::escapeJsString( $message->translation() );
155 - $lines .= " '{$message->key()}': \"{$value}\",\n\n";
 163+ if( $this->keyquote ) {
 164+ $lines .= " '{$message->key()}': \"{$value}\",\n\n";
 165+ } else {
 166+ $lines .= " {$message->key()}: \"{$value}\",\n\n";
 167+ }
156168 }
157169
158170

Status & tagging log