File size: 879 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { localize } from 'i18n-calypso';
import { PureComponent } from 'react';
import './style.scss';

class ReadingTime extends PureComponent {
	render() {
		const words = this.props.words || 0;
		const timeInMinutes = Math.round( this.props.readingTime / 60 );
		let approxTime = null;

		if ( timeInMinutes > 1 ) {
			approxTime = (
				<span className="reading-time__approx">
					({ ' ' }
					{ this.props.translate( '~%d min', {
						args: [ timeInMinutes ],
						context: 'An approximate time to read something, in minutes',
					} ) }
					)
				</span>
			);
		}

		const readingTime = this.props.translate( '%d word {{Time/}}', '%d words {{Time/}}', {
			count: words,
			args: [ words ],
			components: { Time: approxTime },
		} );

		return <span className="byline__reading-time reading-time">{ readingTime }</span>;
	}
}

export default localize( ReadingTime );