diff --git wp-includes/pomo/mo.php wp-includes/pomo/mo.php
index 6ec3524..777d9db 100644
|
|
require_once dirname( __FILE__ ) . '/streams.php'; |
12 | 12 | |
13 | 13 | if ( ! class_exists( 'MO', false ) ) : |
14 | 14 | class MO extends Gettext_Translations { |
| 15 | const SINGULAR_PLURAL_SEPARATOR = "\x0"; |
| 16 | const CONTEXT_SEPARATOR = "\x4"; |
15 | 17 | |
16 | 18 | var $_nplurals = 2; |
17 | 19 | |
… |
… |
if ( ! class_exists( 'MO', false ) ) : |
117 | 119 | // headers' msgid is an empty string |
118 | 120 | fwrite( $fh, pack( 'VV', 0, $current_addr ) ); |
119 | 121 | $current_addr++; |
120 | | $originals_table = chr( 0 ); |
| 122 | $originals_table = self::SINGULAR_PLURAR_SEPARATOR; |
121 | 123 | |
122 | 124 | $reader = new POMO_Reader(); |
123 | 125 | |
124 | 126 | foreach ( $entries as $entry ) { |
125 | | $originals_table .= $this->export_original( $entry ) . chr( 0 ); |
| 127 | $originals_table .= $this->export_original( $entry ) . self::SINGULAR_PLURAR_SEPARATOR; |
126 | 128 | $length = $reader->strlen( $this->export_original( $entry ) ); |
127 | 129 | fwrite( $fh, pack( 'VV', $length, $current_addr ) ); |
128 | 130 | $current_addr += $length + 1; // account for the NULL byte after |
… |
… |
if ( ! class_exists( 'MO', false ) ) : |
131 | 133 | $exported_headers = $this->export_headers(); |
132 | 134 | fwrite( $fh, pack( 'VV', $reader->strlen( $exported_headers ), $current_addr ) ); |
133 | 135 | $current_addr += strlen( $exported_headers ) + 1; |
134 | | $translations_table = $exported_headers . chr( 0 ); |
| 136 | $translations_table = $exported_headers . self::SINGULAR_PLURAR_SEPARATOR; |
135 | 137 | |
136 | 138 | foreach ( $entries as $entry ) { |
137 | | $translations_table .= $this->export_translations( $entry ) . chr( 0 ); |
| 139 | $translations_table .= $this->export_translations( $entry ) . self::SINGULAR_PLURAR_SEPARATOR; |
138 | 140 | $length = $reader->strlen( $this->export_translations( $entry ) ); |
139 | 141 | fwrite( $fh, pack( 'VV', $length, $current_addr ) ); |
140 | 142 | $current_addr += $length + 1; |
… |
… |
if ( ! class_exists( 'MO', false ) ) : |
153 | 155 | //TODO: warnings for control characters |
154 | 156 | $exported = $entry->singular; |
155 | 157 | if ( $entry->is_plural ) { |
156 | | $exported .= chr( 0 ) . $entry->plural; |
| 158 | $exported .= self::SINGULAR_PLURAR_SEPARATOR . $entry->plural; |
157 | 159 | } |
158 | 160 | if ( $entry->context ) { |
159 | | $exported = $entry->context . chr( 4 ) . $exported; |
| 161 | $exported = $entry->context . self::CONTEXT_SEPARATOR . $exported; |
160 | 162 | } |
161 | 163 | return $exported; |
162 | 164 | } |
… |
… |
if ( ! class_exists( 'MO', false ) ) : |
167 | 169 | */ |
168 | 170 | function export_translations( $entry ) { |
169 | 171 | //TODO: warnings for control characters |
170 | | return $entry->is_plural ? implode( chr( 0 ), $entry->translations ) : $entry->translations[0]; |
| 172 | return $entry->is_plural ? implode( self::SINGULAR_PLURAR_SEPARATOR, $entry->translations ) : $entry->translations[0]; |
171 | 173 | } |
172 | 174 | |
173 | 175 | /** |
… |
… |
if ( ! class_exists( 'MO', false ) ) : |
304 | 306 | function &make_entry( $original, $translation ) { |
305 | 307 | $entry = new Translation_Entry(); |
306 | 308 | // look for context |
307 | | $parts = explode( chr( 4 ), $original ); |
| 309 | $parts = explode( self::CONTEXT_SEPARATOR, $original ); |
308 | 310 | if ( isset( $parts[1] ) ) { |
309 | 311 | $original = $parts[1]; |
310 | 312 | $entry->context = $parts[0]; |
311 | 313 | } |
312 | 314 | // look for plural original |
313 | | $parts = explode( chr( 0 ), $original ); |
| 315 | $parts = explode( self::SINGULAR_PLURAR_SEPARATOR, $original ); |
314 | 316 | $entry->singular = $parts[0]; |
315 | 317 | if ( isset( $parts[1] ) ) { |
316 | 318 | $entry->is_plural = true; |
317 | 319 | $entry->plural = $parts[1]; |
318 | 320 | } |
319 | 321 | // plural translations are also separated by \0 |
320 | | $entry->translations = explode( chr( 0 ), $translation ); |
| 322 | $entry->translations = explode( self::SINGULAR_PLURAR_SEPARATOR, $translation ); |
321 | 323 | return $entry; |
322 | 324 | } |
323 | 325 | |