Jump to content
WebFlake

How to format your numbers with comma, point or space character


Courage

Recommended Posts

By default, numbers are formatted with `,` character. To change it with `.` or ` `, you should edit your language locale, but there's another way to do that.
 
Open
 

<forum_path> / admin / sources / classes / class_localization.php

We have 3 options:
 
1. Format with `,` character:
 
njewGwq.png
 
Replace

public function formatNumber( $number, $places=0 )
{ 
      return is_numeric( $number ) ? str_replace( 'x', $this->local_data['thousands_sep'], number_format( $number, $places, $this->local_data['decimal_point'], 'x' ) ) : 0;
}

 
with
 

public function formatNumber( $number, $places=0 )
{ 
      return number_format($number, NULL, '', ',');
}

 
 
 
 
2. Format with `.` character:
TWXrbSl.png
 
 
 
Replace

public function formatNumber( $number, $places=0 )
{ 
      return is_numeric( $number ) ? str_replace( 'x', $this->local_data['thousands_sep'], number_format( $number, $places, $this->local_data['decimal_point'], 'x' ) ) : 0;
}

 
with
 

public function formatNumber( $number, $places=0 )
{ 
      return number_format($number, NULL, '', '.');
}

 
 
3. Format with ` ` (space) character:
dJpUo7F.png
 
 
 
Replace

public function formatNumber( $number, $places=0 )
{ 
      return is_numeric( $number ) ? str_replace( 'x', $this->local_data['thousands_sep'], number_format( $number, $places, $this->local_data['decimal_point'], 'x' ) ) : 0;
}

 
with
 

public function formatNumber( $number, $places=0 )
{ 
      return number_format($number, NULL, '', ' ');
}
Edited by Courage
  • Upvote 3
  • Downvote 3
Link to comment
Share on other sites

×
×
  • Create New...