Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set gender for Locale_bg currency and remove part of check for "and" #31

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions Numbers/Words/Locale/bg.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 <[email protected]>
* @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 = '';
Expand Down Expand Up @@ -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;
Expand All @@ -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 {
Expand Down