Skip to content

Commit

Permalink
i18n: Fix missing number localisation in plugin ratings
Browse files Browse the repository at this point in the history
  • Loading branch information
chriskmnds committed Feb 28, 2025
1 parent 1486a44 commit 43ee34a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
12 changes: 7 additions & 5 deletions client/my-sites/plugins/plugin-ratings/index.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ProgressBar } from '@automattic/components';
import { localize, getLocaleSlug } from 'i18n-calypso';
import { localize, getLocaleSlug, numberFormat } from 'i18n-calypso';
import PropTypes from 'prop-types';
import { Component } from 'react';
import Rating from 'calypso/components/rating';
Expand Down Expand Up @@ -73,11 +73,11 @@ class PluginRatings extends Component {
renderDownloaded() {
let downloaded = this.props.downloaded;
if ( downloaded > 100000 ) {
downloaded = this.props.numberFormat( Math.floor( downloaded / 10000 ) * 10000 ) + '+';
downloaded = numberFormat( Math.floor( downloaded / 10000 ) * 10000 ) + '+';
} else if ( downloaded > 10000 ) {
downloaded = this.props.numberFormat( Math.floor( downloaded / 1000 ) * 1000 ) + '+';
downloaded = numberFormat( Math.floor( downloaded / 1000 ) * 1000 ) + '+';
} else {
downloaded = this.props.numberFormat( downloaded );
downloaded = numberFormat( downloaded );
}

return (
Expand Down Expand Up @@ -119,7 +119,9 @@ class PluginRatings extends Component {
</span>
) }
{ ! hideRatingNumber && rating > 0 && (
<span className="plugin-ratings__number">{ rating / 20 }</span>
<span className="plugin-ratings__number">
{ numberFormat( rating / 20, { decimals: 1 } ) }
</span>
) }
</div>
{ ! inlineNumRatings && numRatings && (
Expand Down
6 changes: 3 additions & 3 deletions client/my-sites/plugins/plugins-browser-item/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Badge, Gridicon } from '@automattic/components';
import { useLocalizeUrl } from '@automattic/i18n-utils';
import { Icon, info } from '@wordpress/icons';
import clsx from 'clsx';
import { getLocaleSlug, useTranslate } from 'i18n-calypso';
import { useTranslate, numberFormat } from 'i18n-calypso';
import { useMemo, useCallback, useEffect, useRef } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { recordTracksEvent } from 'calypso/lib/analytics/tracks';
Expand Down Expand Up @@ -288,13 +288,13 @@ const PluginsBrowserListElement = ( props ) => {
color="#f0b849" // alert-yellow
/>
<span className="plugins-browser-item__rating-value">
{ ( plugin.rating / 20 ).toFixed( 1 ) }
{ numberFormat( plugin.rating / 20, { decimals: 1 } ) }
</span>
{ Number.isInteger( plugin.num_ratings ) && (
<span className="plugins-browser-item__number-of-ratings">
{ translate( '(%(number_of_ratings)s)', {
args: {
number_of_ratings: plugin.num_ratings.toLocaleString( getLocaleSlug() ),
number_of_ratings: numberFormat( plugin.num_ratings ),
},
} ) }
</span>
Expand Down

0 comments on commit 43ee34a

Please sign in to comment.