r79457 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r79456‎ | r79457 | r79458 >
Date:23:30, 1 January 2011
Author:nikerabbit
Status:ok
Tags:
Comment:
Made the group listing in Special:Translate better by making
the top-level group names consistent and sorted.
Modified paths:
  • /trunk/extensions/Translate/SpecialTranslate.php (modified) (history)
  • /trunk/extensions/Translate/groups/MantisBT/MantisBT.yaml (modified) (history)
  • /trunk/extensions/Translate/groups/Mifos/Mifos.yaml (modified) (history)
  • /trunk/extensions/Translate/groups/Okawix/Okawix.yaml (modified) (history)
  • /trunk/extensions/Translate/groups/OpenStreetMap/OpenStreetMap.yaml (modified) (history)
  • /trunk/extensions/Translate/groups/Shapado/Shapado.yaml (modified) (history)
  • /trunk/extensions/Translate/groups/StatusNet/StatusNet.yaml (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/SpecialTranslate.php
@@ -394,8 +394,8 @@
395395 global $wgTranslateGroupStructure;
396396
397397 $groups = MessageGroups::getAllGroups();
 398+
398399 $structure = array();
399 -
400400 foreach ( $groups as $id => $o ) {
401401 if ( !MessageGroups::getGroup( $id )->exists() ) {
402402 continue;
@@ -403,24 +403,30 @@
404404
405405 foreach ( $wgTranslateGroupStructure as $pattern => $hypergroup ) {
406406 if ( preg_match( $pattern, $id ) ) {
407 - /**
408 - * Emulate deepArraySet, because AFAIK php does not have one
409 - */
 407+ // Emulate deepArraySet, because AFAIK php does not have one
410408 self::deepArraySet( $structure, $hypergroup, $id, $o );
411 - /**
412 - * We need to continue the outer loop, because we have finished this item.
413 - */
 409+ // We need to continue the outer loop, because we have finished this item.
414410 continue 2;
415411 }
416412 }
417413
418 - /**
419 - * Does not belong to any subgroup, just shove it into main level.
420 - */
 414+ // Does not belong to any subgroup, just shove it into main level.
421415 $structure[$id] = $o;
422416 }
423417
424 - return $structure;
 418+ // Sort top-level groups according to labels, not ids
 419+ foreach ( $structure as $id => $data ) {
 420+ // Either it is a group itself, or the first group of the array
 421+ $nid = is_array( $data ) ? key( $data ) : $id;
 422+ $labels[$id] = $groups[$nid]->getLabel();
 423+ }
 424+ natcasesort( $labels );
 425+
 426+ foreach ( array_keys( $labels ) as $id ) {
 427+ $sorted[$id] = $structure[$id];
 428+ }
 429+
 430+ return $sorted;
425431 }
426432
427433 /**
Index: trunk/extensions/Translate/groups/Shapado/Shapado.yaml
@@ -34,7 +34,7 @@
3535 ---
3636 BASIC:
3737 id: out-shapado-0-all
38 - label: All Shapado messages
 38+ label: Shapado
3939 display: out/shapado
4040 meta: yes
4141 class: AggregateMessageGroup
Index: trunk/extensions/Translate/groups/MantisBT/MantisBT.yaml
@@ -89,7 +89,7 @@
9090 ---
9191 BASIC:
9292 id: out-mantis-0-all
93 - label: All MantisBT messages
 93+ label: MantisBT
9494 display: out/mantis
9595 description: "{{int:bw-desc-mantisbt}}"
9696 meta: yes
@@ -104,7 +104,7 @@
105105 ---
106106 BASIC:
107107 id: out-mantis-core
108 - label: MantisBT
 108+ label: MantisBT core messages
109109 description: "{{int:bw-desc-mantisbt}}"
110110 display: out/mantis/core
111111
Index: trunk/extensions/Translate/groups/OpenStreetMap/OpenStreetMap.yaml
@@ -16,7 +16,7 @@
1717 ---
1818 BASIC:
1919 id: out-osm-0-all
20 - label: All OpenStreetMap messages
 20+ label: OpenStreetMap
2121 description: "{{int:bw-desc-openstreetmap}}"
2222 display: out/osm
2323 meta: yes
Index: trunk/extensions/Translate/groups/StatusNet/StatusNet.yaml
@@ -28,7 +28,7 @@
2929 ---
3030 BASIC:
3131 id: out-statusnet-0-all
32 - label: All StatusNet messages
 32+ label: StatusNet
3333 display: out/statusnet
3434 meta: yes
3535 class: AggregateMessageGroup
Index: trunk/extensions/Translate/groups/Okawix/Okawix.yaml
@@ -14,7 +14,7 @@
1515 ---
1616 BASIC:
1717 id: out-okawix-0-all
18 - label: All Okawix messages
 18+ label: Okawix
1919 display: out/okawix
2020 meta: yes
2121 class: AggregateMessageGroup
Index: trunk/extensions/Translate/groups/Mifos/Mifos.yaml
@@ -23,7 +23,7 @@
2424 ---
2525 BASIC:
2626 id: out-mifos-0-all
27 - label: All Mifos messages
 27+ label: Mifos
2828 meta: yes
2929 class: AggregateMessageGroup
3030
@@ -33,7 +33,7 @@
3434 ---
3535 BASIC:
3636 id: out-mifos-core
37 - label: Mifos
 37+ label: Mifos core messages
3838 class: FileBasedMessageGroup
3939
4040 FILES:

Status & tagging log