Notifications
Clear all

[Solved] Thousands separator

6 Posts
3 Users
2 Reactions
216 Views
Posts: 3
Topic starter
(@malouk)
Active Member
Joined: 3 years ago

Hello,

Is it possible to change the thousands separator ?

By a space or a punt ?

Tanks

5 Replies
Sofy
Posts: 5322
 Sofy
Admin
(@sofy)
Support Team
Joined: 7 years ago

Hi,

Could you please provide us with a full-page screenshot to help us better understand the issue?

Reply
Posts: 3
Topic starter
(@malouk)
Active Member
Joined: 3 years ago

Hello,

In the French, Belgian, and Swiss systems, the decimal separator is represented by a comma and the thousands separator by a space.

Reply
2 Replies
Sofy
 Sofy
Admin
(@sofy)
Joined: 7 years ago

Support Team
Posts: 5322

@malouk 

You can customize the wpForo theme files.

Please read attentively this doc:   https://wpforo.com/docs/wpforo-v2/forum-themes/theme-files/   You'll find more information about wpForo theme files here

For an update-safe way of customization, please refer to this documentation:   https://wpforo.com/docs/wpforo-v2/forum-themes/theme-customization/

Reply
(@golabs)
Joined: 4 years ago

Trusted Member
Posts: 42

@malouk in pretty much all of Europe and many other countries around the world 🙂

So it would be great to have the choice as a wpForo setting.

Reply
Posts: 3
Topic starter
(@malouk)
Active Member
Joined: 3 years ago

Hello,

The problem stems from the fact that WordPress uses the PHP number_format function instead of the WordPress number_format_i18n function (in the functions.php file).

function wpforo_print_number( $n, $echo = false ) {
	$x      = str_replace( ",", "", $n );
	$x      = intval( $x );
	$n      = 0 + $x;
	$number = 0;
	if( ! is_numeric( $n ) ) return false;
	if( $n > 1000000000000 ) {
		$number = round( ( $n / 1000000000000 ), 1 ) . ' ' . str_replace( '{number}', '', wpforo_phrase( '{number}T', false ) );
	} else if( $n > 1000000000 ) {
		$number = round( ( $n / 1000000000 ), 1 ) . ' ' . str_replace( '{number}', '', wpforo_phrase( '{number}B', false ) );
	} else if( $n > 1000000 ) {
		$number = round( ( $n / 1000000 ), 1 ) . ' ' . str_replace( '{number}', '', wpforo_phrase( '{number}M', false ) );
	} else if( $n > 10000 ) $number = round( ( $n / 1000 ), 1 ) . ' ' . str_replace( '{number}', '', wpforo_phrase( '{number}K', false ) );
	
	$number = ( $number ) ? $number : number_format( $n );
	
	if( $echo ) {
		echo $number;
	} else {
		return $number;
	}
}

this should be

function wpforo_print_number( $n, $echo = false ) {
	$x      = str_replace( ",", "", $n );
	$x      = intval( $x );
	$n      = 0 + $x;
	$number = 0;
	if( ! is_numeric( $n ) ) return false;
	if( $n > 1000000000000 ) {
		$number = round( ( $n / 1000000000000 ), 1 ) . ' ' . str_replace( '{number}', '', wpforo_phrase( '{number}T', false ) );
	} else if( $n > 1000000000 ) {
		$number = round( ( $n / 1000000000 ), 1 ) . ' ' . str_replace( '{number}', '', wpforo_phrase( '{number}B', false ) );
	} else if( $n > 1000000 ) {
		$number = round( ( $n / 1000000 ), 1 ) . ' ' . str_replace( '{number}', '', wpforo_phrase( '{number}M', false ) );
	} else if( $n > 10000 ) $number = round( ( $n / 1000 ), 1 ) . ' ' . str_replace( '{number}', '', wpforo_phrase( '{number}K', false ) );
	
	$number = ( $number ) ? $number : number_format_i18n( $n );
	
	if( $echo ) {
		echo $number;
	} else {
		return $number;
	}
}
Reply