Index: trunk/extensions/Translate/TranslatePage.php |
— | — | @@ -19,7 +19,7 @@ |
20 | 20 | protected $options = null; |
21 | 21 | |
22 | 22 | function __construct() { |
23 | | - SpecialPage::SpecialPage( 'Translate' ); |
| 23 | + parent::__construct( 'Translate' ); |
24 | 24 | } |
25 | 25 | |
26 | 26 | /** |
Index: trunk/extensions/Translate/SpecialTranslationChanges.php |
— | — | @@ -7,7 +7,7 @@ |
8 | 8 | const MSG = 'translationchanges-'; |
9 | 9 | |
10 | 10 | function __construct() { |
11 | | - SpecialPage::SpecialPage( 'TranslationChanges' ); |
| 11 | + parent::__construct( 'TranslationChanges' ); |
12 | 12 | } |
13 | 13 | |
14 | 14 | /** Access point for this special page */ |
Index: trunk/extensions/Translate/TranslateEditAddons.php |
— | — | @@ -14,22 +14,36 @@ |
15 | 15 | |
16 | 16 | static function addNavigation( &$outputpage, &$text ) { |
17 | 17 | global $wgUser, $wgTitle; |
| 18 | + |
18 | 19 | static $done = false; |
19 | | - if ( $done ) return true; |
| 20 | + if ( $done ) { |
| 21 | + return true; |
| 22 | + } |
| 23 | + |
20 | 24 | $done = true; |
21 | 25 | |
22 | | - if ( !self::isMessageNamespace( $wgTitle ) ) return true; |
| 26 | + if ( !self::isMessageNamespace( $wgTitle ) ) { |
| 27 | + return true; |
| 28 | + } |
23 | 29 | |
24 | | - |
25 | 30 | list( $key, $code, $group ) = self::getKeyCodeGroup( $wgTitle ); |
26 | | - if ( $group === null ) return true; |
| 31 | + if ( $group === null ) { |
| 32 | + return true; |
| 33 | + } |
27 | 34 | |
28 | 35 | if ( $group instanceof MessageGroupBase ) { |
29 | 36 | $cache = new MessageGroupCache( $group ); |
30 | | - if ( !$cache->exists() ) return true; |
| 37 | + if ( !$cache->exists() ) { |
| 38 | + return true; |
| 39 | + } |
| 40 | + |
31 | 41 | $keys = $cache->getKeys(); |
32 | 42 | $defs = array(); |
33 | | - foreach ( $keys as $_ ) $defs[$_] = $cache->get( $_ ); |
| 43 | + |
| 44 | + foreach ( $keys as $_ ) { |
| 45 | + $defs[$_] = $cache->get( $_ ); |
| 46 | + } |
| 47 | + |
34 | 48 | $skip = array_merge( $group->getTags( 'ignored' ), $group->getTags( 'optional' ) ); |
35 | 49 | } else { |
36 | 50 | $defs = $group->getDefinitions(); |
— | — | @@ -40,7 +54,10 @@ |
41 | 55 | |
42 | 56 | $next = $prev = $def = null; |
43 | 57 | foreach ( array_keys( $defs ) as $tkey ) { |
44 | | - if ( in_array( $tkey, $skip ) ) continue; |
| 58 | + if ( in_array( $tkey, $skip ) ) { |
| 59 | + continue; |
| 60 | + } |
| 61 | + |
45 | 62 | // Keys can have mixed case, but they have to be unique in a case |
46 | 63 | // insensitive manner. It is therefore safe and a must to use case |
47 | 64 | // insensitive comparison method |
— | — | @@ -52,6 +69,7 @@ |
53 | 70 | $next = $tkey; |
54 | 71 | break; |
55 | 72 | } |
| 73 | + |
56 | 74 | $prev = $tkey; |
57 | 75 | } |
58 | 76 | |
— | — | @@ -69,6 +87,7 @@ |
70 | 88 | if ( !$title->exists() ) { |
71 | 89 | $params['action'] = 'edit'; |
72 | 90 | } |
| 91 | + |
73 | 92 | $prevLink = $skin->link( $title, |
74 | 93 | wfMsgHtml( 'translate-edit-goto-prev' ), array(), $params ); |
75 | 94 | } |
— | — | @@ -114,13 +133,16 @@ |
115 | 134 | |
116 | 135 | static function intro( $object ) { |
117 | 136 | $object->suppressIntro = true; |
| 137 | + |
118 | 138 | return true; |
119 | 139 | } |
120 | 140 | |
121 | 141 | |
122 | 142 | static function addTools( $object ) { |
123 | | - if ( !self::isMessageNamespace( $object->mTitle ) ) return true; |
124 | | - |
| 143 | + if ( !self::isMessageNamespace( $object->mTitle ) ) { |
| 144 | + return true; |
| 145 | + } |
| 146 | + |
125 | 147 | TranslateEditAddons::addNavigation( $ignored, $object->editFormTextTop ); |
126 | 148 | $object->editFormTextTop .= self::editBoxes( $object ); |
127 | 149 | |
— | — | @@ -128,11 +150,18 @@ |
129 | 151 | } |
130 | 152 | |
131 | 153 | static function buttonHack( $editpage, &$buttons, $tabindex ) { |
132 | | - if ( !self::isMessageNamespace( $editpage->mTitle ) ) return true; |
| 154 | + if ( !self::isMessageNamespace( $editpage->mTitle ) ) { |
| 155 | + return true; |
| 156 | + } |
133 | 157 | |
134 | 158 | global $wgLang; |
| 159 | + |
135 | 160 | list( , $code ) = self::figureMessage( $editpage->mTitle ); |
136 | | - if ( $code !== 'qqq' ) return true; |
| 161 | + |
| 162 | + if ( $code !== 'qqq' ) { |
| 163 | + return true; |
| 164 | + } |
| 165 | + |
137 | 166 | $name = TranslateUtils::getLanguageName( $code, false, $wgLang->getCode() ); |
138 | 167 | $temp = array( |
139 | 168 | 'id' => 'wpSave', |
— | — | @@ -144,6 +173,7 @@ |
145 | 174 | 'title' => wfMsg( 'tooltip-save' ) . ' [' . wfMsg( 'accesskey-save' ) . ']', |
146 | 175 | ); |
147 | 176 | $buttons['save'] = Xml::element( 'input', $temp, '' ); |
| 177 | + |
148 | 178 | return true; |
149 | 179 | } |
150 | 180 | |
— | — | @@ -153,6 +183,7 @@ |
154 | 184 | private static function figureMessage( Title $title ) { |
155 | 185 | $text = $title->getDBkey(); |
156 | 186 | $pos = strrpos( $text, '/' ); |
| 187 | + |
157 | 188 | if ( $pos === false ) { |
158 | 189 | $code = ''; |
159 | 190 | $key = $text; |
— | — | @@ -160,12 +191,14 @@ |
161 | 192 | $code = substr( $text, $pos + 1 ); |
162 | 193 | $key = substr( $text, 0, $pos ); |
163 | 194 | } |
| 195 | + |
164 | 196 | return array( $key, $code ); |
165 | 197 | } |
166 | 198 | |
167 | 199 | public static function getKeyCodeGroup( Title $title ) { |
168 | 200 | list( $key, $code ) = self::figureMessage( $title ); |
169 | 201 | $group = self::getMessageGroup( $title->getNamespace(), $key ); |
| 202 | + |
170 | 203 | return array( $key, $code, $group ); |
171 | 204 | } |
172 | 205 | |
— | — | @@ -178,6 +211,7 @@ |
179 | 212 | */ |
180 | 213 | private static function getMessageGroup( $namespace, $key ) { |
181 | 214 | global $wgRequest; |
| 215 | + |
182 | 216 | $group = $wgRequest->getText( 'loadgroup', '' ); |
183 | 217 | $mg = MessageGroups::getGroup( $group ); |
184 | 218 | |
— | — | @@ -205,6 +239,7 @@ |
206 | 240 | |
207 | 241 | TranslateUtils::injectCSS(); |
208 | 242 | $wgOut->includeJQuery(); |
| 243 | + |
209 | 244 | return $th->getBoxes(); |
210 | 245 | } |
211 | 246 | |
— | — | @@ -227,17 +262,22 @@ |
228 | 263 | ); |
229 | 264 | |
230 | 265 | $res = $dbr->selectField( $tables, $fields, $conds, __METHOD__ ); |
| 266 | + |
231 | 267 | return $res === $id; |
232 | 268 | } |
233 | 269 | |
234 | 270 | public static function isMessageNamespace( Title $title ) { |
235 | 271 | global $wgTranslateMessageNamespaces; ; |
| 272 | + |
236 | 273 | $namespace = $title->getNamespace(); |
| 274 | + |
237 | 275 | return in_array( $namespace, $wgTranslateMessageNamespaces, true ); |
238 | 276 | } |
239 | 277 | |
240 | 278 | public static function tabs( $skin, &$tabs ) { |
241 | | - if ( !self::isMessageNamespace( $skin->mTitle ) ) return true; |
| 279 | + if ( !self::isMessageNamespace( $skin->mTitle ) ) { |
| 280 | + return true; |
| 281 | + } |
242 | 282 | |
243 | 283 | unset( $tabs['protect'] ); |
244 | 284 | |
— | — | @@ -246,30 +286,39 @@ |
247 | 287 | |
248 | 288 | public static function keepFields( $edit, $out ) { |
249 | 289 | global $wgRequest; |
| 290 | + |
250 | 291 | $out->addHTML( "\n" . |
251 | 292 | Xml::hidden( 'loadgroup', $wgRequest->getText( 'loadgroup' ) ) . |
252 | 293 | Xml::hidden( 'loadtask', $wgRequest->getText( 'loadtask' ) ) . |
253 | 294 | "\n" |
254 | 295 | ); |
| 296 | + |
255 | 297 | return true; |
256 | 298 | } |
257 | 299 | |
258 | 300 | public static function onSave( $article, $user, $text, $summary, |
259 | | - $minor, $_, $_, $flags, $revision ) { |
260 | | - |
| 301 | + $minor, $_, $_, $flags, $revision |
| 302 | + ) { |
261 | 303 | $title = $article->getTitle(); |
262 | 304 | |
263 | | - if ( !self::isMessageNamespace( $title ) ) return true; |
| 305 | + if ( !self::isMessageNamespace( $title ) ) { |
| 306 | + return true; |
| 307 | + } |
264 | 308 | |
265 | 309 | list( $key, $code, $group ) = self::getKeyCodeGroup( $title ); |
266 | 310 | |
267 | 311 | // Unknown message, do not handle |
268 | | - if ( !$group || !$code ) return true; |
| 312 | + if ( !$group || !$code ) { |
| 313 | + return true; |
| 314 | + } |
269 | 315 | |
270 | 316 | $groups = TranslateUtils::messageKeyToGroups( $title->getNamespace(), $key ); |
271 | 317 | $cache = new ArrayMemoryCache( 'groupstats' ); |
272 | | - foreach ( $groups as $g ) $cache->clear( $g, $code ); |
273 | 318 | |
| 319 | + foreach ( $groups as $g ) { |
| 320 | + $cache->clear( $g, $code ); |
| 321 | + } |
| 322 | + |
274 | 323 | // Check for explicit tag |
275 | 324 | $fuzzy = self::hasFuzzyString( $text ); |
276 | 325 | |
— | — | @@ -277,6 +326,7 @@ |
278 | 327 | global $wgTranslateDocumentationLanguageCode; |
279 | 328 | if ( $code !== $wgTranslateDocumentationLanguageCode ) { |
280 | 329 | $checker = $group->getChecker(); |
| 330 | + |
281 | 331 | if ( $checker ) { |
282 | 332 | $en = $group->getMessage( $key, 'en' ); |
283 | 333 | $message = new FatMessage( $key, $en ); |
— | — | @@ -284,7 +334,9 @@ |
285 | 335 | $message->setTranslation( $text ); |
286 | 336 | |
287 | 337 | $checks = $checker->checkMessage( $message, $code ); |
288 | | - if ( count( $checks ) ) $fuzzy = true; |
| 338 | + if ( count( $checks ) ) { |
| 339 | + $fuzzy = true; |
| 340 | + } |
289 | 341 | } |
290 | 342 | } |
291 | 343 | |
— | — | @@ -315,8 +367,14 @@ |
316 | 368 | // fuzzy> |
317 | 369 | |
318 | 370 | // Diffs for changed messages |
319 | | - if ( $fuzzy !== false ) return true; |
320 | | - if ( $group instanceof WikiPageMessageGroup ) return true; |
| 371 | + if ( $fuzzy !== false ) { |
| 372 | + return true; |
| 373 | + } |
| 374 | + |
| 375 | + if ( $group instanceof WikiPageMessageGroup ) { |
| 376 | + return true; |
| 377 | + } |
| 378 | + |
321 | 379 | $definitionTitle = Title::makeTitleSafe( $title->getNamespace(), "$key/en" ); |
322 | 380 | if ( $definitionTitle && $definitionTitle->exists() ) { |
323 | 381 | $definitionRevision = $definitionTitle->getLatestRevID(); |
— | — | @@ -336,5 +394,4 @@ |
337 | 395 | |
338 | 396 | return true; |
339 | 397 | } |
340 | | - |
341 | 398 | } |
Index: trunk/extensions/Translate/Translate.php |
— | — | @@ -74,7 +74,6 @@ |
75 | 75 | # Translation memory updates |
76 | 76 | $wgHooks['ArticleSaveComplete'][] = 'TranslationMemoryUpdater::update'; |
77 | 77 | |
78 | | - |
79 | 78 | $wgEnablePageTranslation = false; |
80 | 79 | $wgPageTranslationNamespace = 1198; |
81 | 80 | $wgTranslateStaticTags = false; |
— | — | @@ -146,8 +145,8 @@ |
147 | 146 | |
148 | 147 | /** AC = Available classes */ |
149 | 148 | $wgTranslateAC = array( |
150 | | -'core' => 'CoreMessageGroup', |
151 | | -'core-0-mostused' => 'CoreMostUsedMessageGroup', |
| 149 | + 'core' => 'CoreMessageGroup', |
| 150 | + 'core-0-mostused' => 'CoreMostUsedMessageGroup', |
152 | 151 | ); |
153 | 152 | |
154 | 153 | /** |
— | — | @@ -210,7 +209,7 @@ |
211 | 210 | * |
212 | 211 | * You should be able to do this with: |
213 | 212 | * for module in 'YAML::Syck' 'PHP::Serialization' 'File::Slurp'; do cpanp -i $module; done |
214 | | -**/ |
| 213 | + */ |
215 | 214 | $wgTranslateYamlLibrary = 'spyc'; |
216 | 215 | |
217 | 216 | /** |
— | — | @@ -238,7 +237,6 @@ |
239 | 238 | |
240 | 239 | global $wgEnablePageTranslation; |
241 | 240 | if ( $wgEnablePageTranslation ) { |
242 | | - |
243 | 241 | // Special page + the right to use it |
244 | 242 | global $wgSpecialPages, $wgAvailableRights; |
245 | 243 | $wgSpecialPages['PageTranslation'] = 'SpecialPageTranslation'; |
— | — | @@ -280,7 +278,6 @@ |
281 | 279 | $wgHooks['ArticleSave'][] = 'PageTranslationHooks::tpSyntaxCheck'; |
282 | 280 | $wgHooks['EditFilter'][] = 'PageTranslationHooks::tpSyntaxCheckForEditPage'; |
283 | 281 | |
284 | | - |
285 | 282 | // Add transtag to page props for discovery |
286 | 283 | $wgHooks['ArticleSaveComplete'][] = 'PageTranslationHooks::addTranstag'; |
287 | 284 | |
— | — | @@ -355,7 +352,7 @@ |
356 | 353 | |
357 | 354 | /** |
358 | 355 | * Enable tmserver translation memory from translatetoolkit. |
359 | | - * Example configuration: |
| 356 | + * Example configuration: |
360 | 357 | * $wgTranslateTM = array( |
361 | 358 | * 'server' => 'http://127.0.0.1', |
362 | 359 | * 'port' => 54321, |
Index: trunk/extensions/Translate/TranslateTasks.php |
— | — | @@ -40,7 +40,6 @@ |
41 | 41 | public function getPagingCB() { |
42 | 42 | return $this->pagingCB; |
43 | 43 | } |
44 | | - |
45 | 44 | } |
46 | 45 | |
47 | 46 | /** |