Skip to content

Conversation

@PhilippeThouvenot
Copy link
Contributor

@PhilippeThouvenot PhilippeThouvenot commented Aug 25, 2025

I need to override currency symbol to format number without symbol.
But I want to keep the currency formating.
So, for this I have made this pull request to override symbol.

Actually :

\Illuminate\Support\Number::useLocale('fr_CH');
\Illuminate\Support\Number::useCurrency('CHF');

Number::currency(1000000.25, precision: 2);
1 000 000.25 CHF

Number::format(1000000.25, precision: 2);
1 000 000,25

Expected :

Number::currency(1000000.25, precision: 2, symbol: '');
1 000 000.25 

@shaedrich
Copy link
Contributor

Why don't you use normal number formatting?

@taylorotwell taylorotwell merged commit 568926f into laravel:12.x Aug 25, 2025
19 of 60 checks passed
@PhilippeThouvenot
Copy link
Contributor Author

You don't have the same resul when normal formating and currency formating.

src/Illuminate/Support/Number.php:190
$formatter = new NumberFormatter($locale ?? static::$locale, NumberFormatter::CURRENCY);
src/Illuminate/Support/Number.php:40
$formatter = new NumberFormatter($locale ?? static::$locale, NumberFormatter::DECIMAL);

The result between us is not the same, check my example.

@shaedrich
Copy link
Contributor

That might be, but shouldn't it be the same? You shouldn't be abusing this method for what it's not supposed to

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants