From e66b658130dd3378b63f75b873e9b7fbbae0bf2f Mon Sep 17 00:00:00 2001 From: Valentina Stankova Date: Tue, 28 Nov 2017 17:09:39 +0200 Subject: [PATCH 1/2] Use param to set propper gender for bg currency --- Numbers/Words/Locale/bg.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Numbers/Words/Locale/bg.php b/Numbers/Words/Locale/bg.php index 3b09e18..c7cdb85 100644 --- a/Numbers/Words/Locale/bg.php +++ b/Numbers/Words/Locale/bg.php @@ -442,15 +442,22 @@ function _showDigitsGroup($num, $gender = 0, $last = false) * * @param integer $num An integer between 9.99*-10^302 and 9.99*10^302 (999 centillions) * that need to be converted to words - * + * @param integer $gender An integer used to set currency gender + * 0 - neuter - for non-currency numbers + * 1 - masculine - for integer numbers ("lv.") + * -1 - feminine - for numbers after floating point ("stotinki") * @return string The corresponding word representation * * @access protected * @author Kouber Saparev * @since Numbers_Words 0.16.3 */ - function _toWords($num = 0) + function _toWords($num = 0, $gender = 0) { + if (empty($gender) || !in_array($gender, [-1, 0, 1])) { + $gender = 0; + } + $ret = array(); $ret_minus = ''; @@ -493,7 +500,7 @@ function _toWords($num = 0) if ($num_groups[$i]!='000') { if ($num_groups[$i]>1) { if ($pow==1) { - $ret[$j] .= $this->_showDigitsGroup($num_groups[$i], 0, !$this->_last_and && $i).$this->_sep; + $ret[$j] .= $this->_showDigitsGroup($num_groups[$i], $gender, !$this->_last_and && $i).$this->_sep; $ret[$j] .= $this->_exponent[($pow-1)*3]; } elseif ($pow==2) { $ret[$j] .= $this->_showDigitsGroup($num_groups[$i], -1, !$this->_last_and && $i).$this->_sep; @@ -504,7 +511,7 @@ function _toWords($num = 0) } } else { if ($pow==1) { - $ret[$j] .= $this->_showDigitsGroup($num_groups[$i], 0, !$this->_last_and && $i).$this->_sep; + $ret[$j] .= $this->_showDigitsGroup($num_groups[$i], $gender, !$this->_last_and && $i).$this->_sep; } elseif ($pow==2) { $ret[$j] .= $this->_exponent[($pow-1)*3].$this->_sep; } else { From fbdccb2b513b6ded2707d770da6f1a1df3a9997f Mon Sep 17 00:00:00 2001 From: Valentina Stankova Date: Tue, 28 Nov 2017 17:11:27 +0200 Subject: [PATCH 2/2] Correct check for last "and" --- Numbers/Words/Locale/bg.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Numbers/Words/Locale/bg.php b/Numbers/Words/Locale/bg.php index c7cdb85..6f11eca 100644 --- a/Numbers/Words/Locale/bg.php +++ b/Numbers/Words/Locale/bg.php @@ -421,7 +421,7 @@ function _showDigitsGroup($num, $gender = 0, $last = false) // put "and" optionally in the case this is the last non-empty group if ($last) { - if (!$s||count($ret)==1) { + if (count($ret)==1) { $ret[0] = $this->_and; } $this->_last_and = true;