Index: trunk/extensions/Translate/ffs/OpenLayers.php |
— | — | @@ -8,6 +8,8 @@ |
9 | 9 | */ |
10 | 10 | |
11 | 11 | class OpenLayersFormatReader extends SimpleFormatReader { |
| 12 | + protected $keyquote = true; |
| 13 | + |
12 | 14 | private static function unescapeJsString( $string ) { |
13 | 15 | // See ECMA 262 section 7.8.4 for string literal format |
14 | 16 | $pairs = array( |
— | — | @@ -81,7 +83,11 @@ |
82 | 84 | $segment = implode( $segment ); |
83 | 85 | # $segment = preg_replace( '#\" \+(.*?)\"#m', '', $segment ); |
84 | 86 | // 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 | + } |
86 | 92 | $key = $segments[ 0 ]; |
87 | 93 | unset( $segments[ 0 ] ); |
88 | 94 | $value = implode( $segments ); |
— | — | @@ -89,7 +95,9 @@ |
90 | 96 | $key = trim( $key ); |
91 | 97 | $value = trim( $value ); |
92 | 98 | // Remove quotation marks and syntax. |
93 | | - $key = substr( $key, 1 ); |
| 99 | + if( $this->keyquote ) { |
| 100 | + $key = substr( $key, 1 ); |
| 101 | + } |
94 | 102 | $value = substr( $value, 1, -1 ); |
95 | 103 | $messages[ $key ] = self::unescapeJsString( $value ); |
96 | 104 | } |
— | — | @@ -151,7 +159,11 @@ |
152 | 160 | foreach ( $collection as $message ) { |
153 | 161 | $key = Xml::escapeJsString( $message->key() ); |
154 | 162 | $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 | + } |
156 | 168 | } |
157 | 169 | |
158 | 170 | |