Skip to content

Commit 8d4a53a

Browse files
committed
Merge branch 'develop' into 2.x
2 parents 8a15889 + f14d9e1 commit 8d4a53a

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ Almost every configuration value can be overrided dinamically by methods.
358358
- currencyDecimalPoint(string)
359359
- currencyThousandsSeparator(string)
360360
- currencyFormat(string)
361-
- getAmountInWords(float) - Spells out float to words (only english)
361+
- getAmountInWords(float, ?string $locale) - Spells out float to words, second parameter is locale
362362
- getTotalAmountInWords() - spells out total_amount
363363
- formatCurrency(float) - returns formatted value with currency settings '$ 1,99'
364364

src/Traits/CurrencyFormatter.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace LaravelDaily\Invoices\Traits;
44

5+
use Illuminate\Support\Facades\App;
56
use NumberFormatter;
67

78
/**
@@ -144,12 +145,13 @@ public function formatCurrency(float $amount)
144145

145146
/**
146147
* @param float $amount
148+
* @param string|null $locale
147149
* @return string
148150
*/
149-
public function getAmountInWords(float $amount)
151+
public function getAmountInWords(float $amount, ?string $locale = null)
150152
{
151153
$amount = number_format($amount, $this->currency_decimals, '.', '');
152-
$formatter = new NumberFormatter('en', NumberFormatter::SPELLOUT);
154+
$formatter = new NumberFormatter($locale ?? App::getLocale(), NumberFormatter::SPELLOUT);
153155

154156
$value = explode('.', $amount);
155157

0 commit comments

Comments
 (0)