Announcement

Collapse
No announcement yet.

sc_format_num() not handling internationalization

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • sc_format_num() not handling internationalization

    I am seeing the sc_format_num() is no different to PHP number_format. I would suggest to implement the sc_format_num or adding another macro that using PHP NumberFormatter.

    My code example,

    Code:
    $sql = "SELECT SUM(quantity * unitPrice) FROM purchase_detail WHERE purchaseFk = {id}";
    sc_lookup(dataset, $sql);
    
    $total = 0;
    
    if(!empty({dataset[0][0]})) {
    	$total = {dataset[0][0]};
    }
    
    $num = new NumberFormatter(sc_get_regional(), NumberFormatter::DECIMAL);
    {total} = $num->format($total);
    By using NumberFormatter, we also handle the internationalization when formatting our number. I understand that NumberFormatter is only available for PHP 5.3 and above. This may cause the compatibility issue. Nevertheles, I expect the sc_format_num() to handle the internationalization since one of the main point in using scriptcase is internationalization.
Working...
X