r79603 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r79602‎ | r79603 | r79604 >
Date:21:45, 4 January 2011
Author:krinkle
Status:deferred
Tags:
Comment:
- No longer needed if-check
- Using ms.msg() instead in ext.translate.langstats
- Adding 'en' and 'qqq' messages
Follow-up of r79597 and r79601
Modified paths:
  • /trunk/extensions/Translate/Translate.i18n.php (modified) (history)
  • /trunk/extensions/Translate/Translate.php (modified) (history)
  • /trunk/extensions/Translate/js/translate.langstats.js (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/js/translate.langstats.js
@@ -4,72 +4,66 @@
55 * @created January 3, 2011
66 * @license GPL v2, CC-BY-SA-3.0
77 */
8 -var MSGexpand = 'expand', MSGcollapse = 'collapse', MSGexpandall = 'expand all', MSGcollapseall = 'collapse all';
98 jQuery( document ).ready( function() {
10 - if ( mw.config.get( 'wgPageName' ) == 'Special:LanguageStats' ) {
119
12 - var $translateTable = $( '.mw-sp-translate-table' ),
13 - $metaRows = $( 'tr[data-ismeta=1]', $translateTable );
 10+ var $translateTable = $( '.mw-sp-translate-table' ),
 11+ $metaRows = $( 'tr[data-ismeta=1]', $translateTable ),
1412
15 - // Only do stuff if there are any meta group rows on this pages
16 - if ( $metaRows.size() ) {
 13+ // Only do stuff if there are any meta group rows on this pages
 14+ if ( $metaRows.size() ) {
1715
18 - var $allChildRows = $( 'tr[data-parentgroups]', $translateTable ),
19 - $toggleAllButton = $( '<span class="mw-sp-langstats-expander">[<a href="#" onclick="return false;">' + MSGexpandall + '</a>]</span>' ).click( function() {
20 - var $el = $( this ),
21 - $allToggles = $( '.mw-sp-langstats-toggle', $translateTable );
 16+ var $allChildRows = $( 'tr[data-parentgroups]', $translateTable ),
 17+ $allToggles = $( '.mw-sp-langstats-toggle', $translateTable ),
 18+ $toggleAllButton = $( '<span class="mw-sp-langstats-expander">[</span>' ).append( $( '<a href="#" onclick="return false;">' ).text( mw.msg( 'translate-langstats-expandall' ) ) ).append( ']' ).click( function() {
 19+ var $el = $( this );
 20+ // Switch the state and toggle the rows
 21+ // and update the local toggles too
 22+ if ( $el.hasClass( 'mw-sp-langstats-expander' ) ) {
 23+ $allChildRows.show();
 24+ $el.add( $allToggles ).removeClass( 'mw-sp-langstats-expander' ).addClass( 'mw-sp-langstats-collapser' )
 25+ $el.find( '> a' ).text( mw.msg( 'translate-langstats-collapseall' ) );
 26+ $allToggles.find( '> a' ).text( mw.msg( 'translate-langstats-collapse' ) );
 27+ } else {
 28+ $allChildRows.hide();
 29+ $el.add( $allToggles ).addClass( 'mw-sp-langstats-expander' ).removeClass( 'mw-sp-langstats-collapser' )
 30+ $el.find( '> a' ).text( mw.msg( 'translate-langstats-expandall' ) );
 31+ $allToggles.find( '> a' ).text( mw.msg( 'translate-langstats-expand' ) );
 32+ }
 33+ } );
 34+
 35+ // Initially hide them
 36+ $allChildRows.hide();
 37+
 38+ // Add the toggle-all button above the table
 39+ $( '<p class="mw-sp-langstats-toggleall"></p>' ).append( $toggleAllButton ).insertBefore( $translateTable );
 40+
 41+ $metaRows.each( function() {
 42+ // Get info and cache selectors
 43+ var $thisGroup = $(this),
 44+ thisGroupId = $thisGroup.attr( 'data-groupid' ),
 45+ $thisChildRows = $( 'tr[data-parentgroups~="' + thisGroupId + '"]', $translateTable );
 46+
 47+ // Only do the collapse stuff if this Meta-group actually has children on this page
 48+ if ( $thisChildRows.size() ) {
 49+
 50+ // Build toggle link
 51+ var $toggler = $( '<span class="mw-sp-langstats-toggle mw-sp-langstats-expander">[</span>' ).append( $( '<a href="#" onclick="return false;">' ).text( mw.msg( 'translate-langstats-expand' ) ) ).append( ']' ).click( function() {
 52+ var $el = $( this );
2253 // Switch the state and toggle the rows
23 - // and update the local toggles too
2454 if ( $el.hasClass( 'mw-sp-langstats-expander' ) ) {
25 - $allChildRows.fadeIn();
26 - $el.add( $allToggles ).removeClass( 'mw-sp-langstats-expander' ).addClass( 'mw-sp-langstats-collapser' )
27 - $el.find( '> a' ).text( MSGcollapseall );
28 - $allToggles.find( '> a' ).text( MSGcollapse );
 55+ $thisChildRows.fadeIn();
 56+ $el.removeClass( 'mw-sp-langstats-expander' ).addClass( 'mw-sp-langstats-collapser' )
 57+ .find( '> a' ).text( mw.msg( 'translate-langstats-collapse' ) );
2958 } else {
30 - $allChildRows.fadeOut();
31 - $el.add( $allToggles ).addClass( 'mw-sp-langstats-expander' ).removeClass( 'mw-sp-langstats-collapser' )
32 - $el.find( '> a' ).text( MSGexpandall );
33 - $allToggles.find( '> a' ).text( MSGexpand );
 59+ $thisChildRows.fadeOut();
 60+ $el.addClass( 'mw-sp-langstats-expander' ).removeClass( 'mw-sp-langstats-collapser' )
 61+ .find( '> a' ).text( mw.msg( 'translate-langstats-expand' ) );
3462 }
3563 } );
3664
37 - // Initially hide them
38 - $allChildRows.hide();
39 -
40 - // Add the toggle-all button above the table
41 - $( '<p class="mw-sp-langstats-toggleall"></p>' ).append( $toggleAllButton ).insertBefore( $translateTable );
42 -
43 - $metaRows.each( function() {
44 - // Get info and cache selectors
45 - var $thisGroup = $(this),
46 - thisGroupId = $thisGroup.attr( 'data-groupid' ),
47 - $thisChildRows = $( 'tr[data-parentgroups~="' + thisGroupId + '"]', $translateTable );
48 -
49 - // Only do the collapse stuff if this Meta-group actually has children on this page
50 - if ( $thisChildRows.size() ) {
51 -
52 - // Build toggle link
53 - var $toggler = $( '<span class="mw-sp-langstats-toggle mw-sp-langstats-expander">[<a href="#" onclick="return false;">' + MSGexpand + '</a>]</span>' ).click( function() {
54 - var $el = $( this );
55 - // Switch the state and toggle the rows
56 - if ( $el.hasClass( 'mw-sp-langstats-expander' ) ) {
57 - $thisChildRows.fadeIn();
58 - $el.removeClass( 'mw-sp-langstats-expander' ).addClass( 'mw-sp-langstats-collapser' )
59 - .find( '> a' ).text( MSGcollapse );
60 - } else {
61 - $thisChildRows.fadeOut();
62 - $el.addClass( 'mw-sp-langstats-expander' ).removeClass( 'mw-sp-langstats-collapser' )
63 - .find( '> a' ).text( MSGexpand );
64 - }
65 - } );
66 -
67 - // Add the toggle link to the first cell of the meta group table-row
68 - $thisGroup.find( ' > td:first' ).append( $toggler );
69 - }
70 - } );
71 - }
 65+ // Add the toggle link to the first cell of the meta group table-row
 66+ $thisGroup.find( ' > td:first' ).append( $toggler );
 67+ }
 68+ } );
7269 }
73 -} );
74 -// @TODO: Create the following messages "translate-expand-all" (new), "translate-collapse-all" (new), "translate-expand" ({{Identical|collapsible-expand}}) and "translate-collapse" ({{Identical|collapsible-collapse}})
75 -// @TODO: Load this script via ResourceLoader and pass the those 4 messages
76 -// @TODO: Replace hardcoded messages with mw.msg('');
\ No newline at end of file
 70+} );
\ No newline at end of file
Index: trunk/extensions/Translate/Translate.php
@@ -128,6 +128,7 @@
129129 $wgResourceModules['ext.translate.langstats'] = array(
130130 'scripts' => 'js/translate.langstats.js',
131131 'styles' => 'js/translate.langstats.css',
 132+ 'messages' => array( 'translate-langstats-expandall', 'translate-langstats-collapseall', 'translate-langstats-expand', 'translate-langstats-collapse' ),
132133 'localBasePath' => dirname( __FILE__ ),
133134 'remoteExtPath' => 'Translate',
134135 );
Index: trunk/extensions/Translate/Translate.i18n.php
@@ -219,6 +219,10 @@
220220 'languagestats-summary' => 'This page shows translation statistics for all message groups for a language.',
221221 'languagestats-stats-for' => 'Translation statistics for $1 ($2).',
222222 'languagestats-recenttranslations' => 'recent translations',
 223+ 'translate-langstats-expand' => 'expand',
 224+ 'translate-langstats-collapse' => 'collapse',
 225+ 'translate-langstats-expandall' => 'expand all',
 226+ 'translate-langstats-collapseall' => 'collapse all',
223227 'translate-language-code' => 'Language code',
224228 'translate-language-code-field-name' => 'Language code:',
225229 'translate-suppress-complete' => 'Suppress completely translated message groups',
@@ -470,6 +474,10 @@
471475 'translate-language-code-field-name' => 'Used in [[Special:LanguageStats]].
472476
473477 {{Identical|Language code}}',
 478+ 'translate-langstats-expand' => 'Used in [[Special:LanguageStats]] to expand subgroups {{Identical/Expand}}',
 479+ 'translate-langstats-collapse' => 'Used in [[Special:LanguageStats]] to collapse subgroups {{Identical/Collapse}}',
 480+ 'translate-langstats-expandall' => 'Used in [[Special:LanguageStats]] to expand all subgroups',
 481+ 'translate-langstats-collapseall' => 'Used in [[Special:LanguageStats]] to collapse all subgroups',
474482 'translate-suppress-complete' => 'Used in [[Special:LanguageStats]].',
475483 'translate-language' => '{{Identical|Language}}',
476484 'translate-untranslated' => 'Column header in [[Special:LanguageStats]] for number of untranslated messages in a message group.',

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r79597adding initial version of ext.translate.langstats modulekrinkle21:03, 4 January 2011
r79601undoing accidential collision/revert of r79598krinkle21:17, 4 January 2011

Status & tagging log