Index: trunk/extensions/Translate/scripts/magic-export-2.php |
— | — | @@ -71,9 +71,18 @@ |
72 | 72 | if ( !file_exists( $file ) ) continue; |
73 | 73 | |
74 | 74 | include( $file ); |
75 | | - if( !isset( $aliases ) ) continue; |
76 | | - $messagesOld[$group->getId()] = $aliases; |
77 | | - unset( $aliases ); |
| 75 | + switch( $type ) { |
| 76 | + case 'special': |
| 77 | + if( !isset( $aliases ) ) continue; |
| 78 | + $messagesOld[$group->getId()] = $aliases; |
| 79 | + unset( $aliases ); |
| 80 | + break; |
| 81 | + case 'magic': |
| 82 | + if( !isset( $magicWords ) ) continue; |
| 83 | + $messagesOld[$group->getId()] = $magicWords; |
| 84 | + unset( $magicWords ); |
| 85 | + break; |
| 86 | + } |
78 | 87 | |
79 | 88 | $handles[$group->getId()] = fopen( $options['target'] . '/' . $filename, 'w' ); |
80 | 89 | |
— | — | @@ -83,7 +92,7 @@ |
84 | 93 | // Write header. |
85 | 94 | foreach( $handles as $handle ) { |
86 | 95 | if( $type === 'special' ) { |
87 | | - fwrite( $handle, <<<EOT |
| 96 | + fwrite( $handle, <<<EOT |
88 | 97 | <?php |
89 | 98 | |
90 | 99 | /** |
— | — | @@ -97,6 +106,18 @@ |
98 | 107 | EOT |
99 | 108 | ); |
100 | 109 | } else { |
| 110 | + fwrite( $handle, <<<EOT |
| 111 | + |
| 112 | +/** |
| 113 | + * Internationalisation file for magic |
| 114 | + * |
| 115 | + * @file |
| 116 | + * @ingroup Extensions |
| 117 | + */ |
| 118 | + |
| 119 | +\$magicWords = array(); |
| 120 | +EOT |
| 121 | + ); |
101 | 122 | } |
102 | 123 | } |
103 | 124 | |
— | — | @@ -150,13 +171,36 @@ |
151 | 172 | } |
152 | 173 | } |
153 | 174 | if( count( $messagesOut ) > 0 ) { |
154 | | - $out = "\n\n/** {$namesEn[$l]} ({$namesNative[$l]}) */\n\$aliases['{$l}'] = array(\n"; |
| 175 | + switch( $options['type'] ) { |
| 176 | + case 'special': |
| 177 | + $out = "\n\n/** {$namesEn[$l]} ({$namesNative[$l]}) */\n\$aliases['{$l}'] = array(\n"; |
| 178 | + break; |
| 179 | + case 'magic': |
| 180 | + $out = "\n\n/** {$namesEn[$l]} ({$namesNative[$l]}) */\n\$magicWords['{$l}'] = array(\n"; |
| 181 | + break; |
| 182 | + } |
155 | 183 | foreach( $messagesOut as $key => $translations ) { |
156 | 184 | foreach( $translations as $id => $translation ) { |
157 | 185 | $translations[$id] = addslashes( $translation ); |
| 186 | + if( $options['type'] === 'magic' ) { |
| 187 | + if( $translation === '0' ) { |
| 188 | + unset( $translations[$id] ); |
| 189 | + } |
| 190 | + } |
158 | 191 | } |
159 | 192 | $translations = implode( "', '", $translations ); |
160 | | - $out .= "\t'$key' => array( '$translations' ),\n"; |
| 193 | + switch( $options['type'] ) { |
| 194 | + case 'special': |
| 195 | + $out .= "\t'$key' => array( '$translations' ),\n"; |
| 196 | + break; |
| 197 | + case 'magic': |
| 198 | + if( $messagesOld['ext-babel']['en'][$key][0] === 0 ) { |
| 199 | + $out .= "\t'$key' => array( 0, '$translations' ),\n"; |
| 200 | + } else { |
| 201 | + $out .= "\t'$key' => array( '$translations' ),\n"; |
| 202 | + } |
| 203 | + break; |
| 204 | + } |
161 | 205 | } |
162 | 206 | $out .= ");"; |
163 | 207 | fwrite( $handle, $out ); |