@@ -649,24 +649,27 @@ export function useCharts() {
649649
650650 const granularity = String ( config . $t ( granularityKey ) ) . toLocaleLowerCase ( )
651651
652- const trendKeyByTrend : Record < string , string > = {
653- none : 'package.trends.copy_alt.trend_none' ,
654- weak : 'package.trends.copy_alt.trend_weak' ,
655- strong : 'package.trends.copy_alt.trend_strong' ,
656- undefined : 'package.trends.copy_alt.trend_undefined' ,
657- }
658-
659652 const packages_analysis = analysis
660653 . map ( ( pkg , i ) => {
661- const trendKey =
662- trendKeyByTrend [ pkg . interpretation . trend as unknown as string ] ??
663- 'package.trends.copy_alt.trend_undefined'
654+ const trendText = ( ( ) => {
655+ switch ( pkg . interpretation . trend ) {
656+ case 'none' :
657+ return config . $t ( 'package.trends.copy_alt.trend_none' )
658+ case 'weak' :
659+ return config . $t ( 'package.trends.copy_alt.trend_weak' )
660+ case 'strong' :
661+ return config . $t ( 'package.trends.copy_alt.trend_strong' )
662+ case 'undefined' :
663+ default :
664+ return config . $t ( 'package.trends.copy_alt.trend_undefined' )
665+ }
666+ } ) ( )
664667
665668 return config . $t ( 'package.trends.copy_alt.analysis' , {
666669 package_name : pkg . name ,
667670 start_value : config . formattedDatasetValues [ i ] ?. [ 0 ] ?? 0 ,
668671 end_value : config . formattedDatasetValues [ i ] ?. at ( - 1 ) ?? 0 ,
669- trend : config . $t ( trendKey ) ,
672+ trend : trendText ,
670673 downloads_slope : compactNumberFormatter . value . format ( pkg . slope ) ,
671674 growth_percentage : `${ pkg . progressionPercent ?. toFixed ( 1 ) } %` ,
672675 } )
0 commit comments