Nikerabbit has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/216102

Change subject: Apply number formatting on new stats design
......................................................................

Apply number formatting on new stats design

Change-Id: I690d62b28338e6279b099db3f5295d82d7a5fdb7
---
M modules/stats/ext.cx.stats.js
1 file changed, 50 insertions(+), 19 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation 
refs/changes/02/216102/1

diff --git a/modules/stats/ext.cx.stats.js b/modules/stats/ext.cx.stats.js
index f150023..8fd00b7 100644
--- a/modules/stats/ext.cx.stats.js
+++ b/modules/stats/ext.cx.stats.js
@@ -69,7 +69,8 @@
                        lastWeekTotal, lastWeekLangTotal, weekTrend = 0,
                        weekLangTrend = 0,
                        lastWeekLangTranslations, prevWeekLangTotal, 
lastWeekTranslations,
-                       prevWeekTotal, prevWeekTranslations, 
prevWeekLangTranslations;
+                       prevWeekTotal, prevWeekTranslations, 
prevWeekLangTranslations,
+                       fmt = mw.language.convertNumber;
 
                if ( this.totalTranslationTrend.length < 3 ) {
                        // Trend calculation works if we have enough data
@@ -104,25 +105,44 @@
                $total = $( '<div>' )
                        .addClass( 'cx-stats-box' )
                        .append(
-                               $( '<div>' ).addClass( 'cx-stats-box__title' 
).text( mw.msg( 'cx-stats-total-published' ) ),
-                               $( '<div>' ).addClass( 'cx-stats-box__total' 
).text( total ),
-                               $( '<div>' ).addClass( 
'cx-stats-box__localtotal' )
-                               .text( mw.msg( 'cx-stats-local-published', 
langTotal, localLanguage ) )
+                               $( '<div>' )
+                                       .addClass( 'cx-stats-box__title' )
+                                       .text( mw.msg( 
'cx-stats-total-published' ) ),
+                               $( '<div>' )
+                                       .addClass( 'cx-stats-box__total' )
+                                       .text( fmt( total ) ),
+                               $( '<div>' )
+                                       .addClass( 'cx-stats-box__localtotal' )
+                                       .text( mw.msg(
+                                               'cx-stats-local-published',
+                                               fmt( langTotal ),
+                                               fmt( localLanguage )
+                                       )
+                               )
                        );
 
                $weeklyStats = $( '<div>' )
                        .addClass( 'cx-stats-box' )
                        .append(
-                               $( '<div>' ).addClass( 'cx-stats-box__title' 
).text( mw.msg( 'cx-stats-weekly-published' ) ),
+                               $( '<div>' )
+                                       .addClass( 'cx-stats-box__title' )
+                                       .text( mw.msg( 
'cx-stats-weekly-published' ) ),
                                $( '<div>' ).append(
-                                       $( '<span>' ).addClass( 
'cx-stats-box__total' ).text( lastWeekTranslations ),
                                        $( '<span>' )
-                                       .addClass( 'cx-stats-box__trend ' + ( 
weekTrend >= 0 ? 'increase' : 'decrease' ) )
-                                       .text( mw.msg( 'percent', weekTrend ) )
+                                               .addClass( 
'cx-stats-box__total' )
+                                               .text( fmt( 
lastWeekTranslations ) ),
+                                       $( '<span>' )
+                                               .addClass( 'cx-stats-box__trend 
' + ( weekTrend >= 0 ? 'increase' : 'decrease' ) )
+                                               .text( mw.msg( 'percent', fmt( 
weekTrend ) ) )
                                ),
-                               $( '<div>' ).addClass( 
'cx-stats-box__localtotal' )
-                               .text( mw.msg( 'cx-stats-local-published',
-                                       lastWeekLangTranslations + '(' + 
mw.msg( 'percent', weekLangTrend ) + ')', localLanguage ) )
+                               $( '<div>' )
+                                       .addClass( 'cx-stats-box__localtotal' )
+                                       .text( mw.msg(
+                                               'cx-stats-local-published',
+                                               fmt( lastWeekLangTranslations ) 
+ '('
+                                                       + mw.msg( 'percent', 
fmt( weekLangTrend ) ) + ')',
+                                               localLanguage
+                                       ) )
                        );
                this.$highlights.append( $total, $weeklyStats );
        };
@@ -219,7 +239,8 @@
                        $callout,
                        $row, width, max = 0,
                        $tail, tailWidth = 0,
-                       tail;
+                       tail,
+                       fmt = mw.language.convertNumber;
 
                $chart = $( '<div>' ).addClass( 'cx-stats-chart' );
 
@@ -250,7 +271,7 @@
                                max = Math.ceil( model[ i ][ property ] / 100 ) 
* 100;
                                $rows.push( $( '<div>' )
                                        .addClass( 'cx-stats-chart__row 
seperator' )
-                                       .text( mw.msg( 
'cx-stats-grouping-title', mw.language.convertNumber( max ) ) ) );
+                                       .text( mw.msg( 
'cx-stats-grouping-title', fmt( max ) ) ) );
                        }
 
                        $callout = $( '<table>' ).addClass( 
'cx-stats-chart__callout' );
@@ -273,8 +294,12 @@
                                }
 
                                $callout.append( $( '<tr>' ).append(
-                                       $( '<td>' ).addClass( 
'cx-stats-chart__callout-count' ).text( translations[ j ][ property ] ),
-                                       $( '<td>' ).addClass( 
'cx-stats-chart__callout-lang' ).text( $.uls.data.getAutonym( translations[ j ][
+                                       $( '<td>' )
+                                               .addClass( 
'cx-stats-chart__callout-count' )
+                                               .text( fmt( translations[ j ][ 
property ] ) ),
+                                       $( '<td>' )
+                                               .addClass( 
'cx-stats-chart__callout-lang' )
+                                               .text( $.uls.data.getAutonym( 
translations[ j ][
                                                        direction === 'to' ? 
'sourceLanguage' : 'targetLanguage' ] ) )
                                ) );
                        }
@@ -299,9 +324,15 @@
                        }
 
                        $row.append(
-                               $( '<span>' ).addClass( 
'cx-stats-chart__langcode' ).text( model[ i ].language ),
-                               $( '<span>' ).addClass( 
'cx-stats-chart__autonym' ).text( $.uls.data.getAutonym( model[ i ].language ) 
),
-                               $( '<span>' ).addClass( 'cx-stats-chart__total' 
).text( model[ i ][ property ] ),
+                               $( '<span>' )
+                                       .addClass( 'cx-stats-chart__langcode' )
+                                       .text( model[ i ].language ),
+                               $( '<span>' )
+                                       .addClass( 'cx-stats-chart__autonym' )
+                                       .text( $.uls.data.getAutonym( model[ i 
].language ) ),
+                               $( '<span>' )
+                                       .addClass( 'cx-stats-chart__total' )
+                                       .text( fmt( model[ i ][ property ] ) ),
                                $translations
                        );
 

-- 
To view, visit https://gerrit.wikimedia.org/r/216102
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I690d62b28338e6279b099db3f5295d82d7a5fdb7
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Nikerabbit <niklas.laxst...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to