Skip to content

Commit ec528f7

Browse files
committed
feat(localization): added nullable parameter $locale to getAmountInWords()
1 parent 4e06eeb commit ec528f7

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/Traits/CurrencyFormatter.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,12 +144,13 @@ public function formatCurrency(float $amount)
144144

145145
/**
146146
* @param float $amount
147+
* @param string|null $locale
147148
* @return string
148149
*/
149-
public function getAmountInWords(float $amount)
150+
public function getAmountInWords(float $amount, ?string $locale = null)
150151
{
151152
$amount = number_format($amount, $this->currency_decimals, '.', '');
152-
$formatter = new NumberFormatter('en', NumberFormatter::SPELLOUT);
153+
$formatter = new NumberFormatter($locale ?? config('app.locale', 'en'), NumberFormatter::SPELLOUT);
153154

154155
$value = explode('.', $amount);
155156

0 commit comments

Comments
 (0)