kwn / number-to-words

Number to string standalone PHP library with i18n. Drivers for numbers and currency included.
MIT License
384 stars 157 forks source link

Using $digits masculine form #63

Closed DPlachkov closed 3 years ago

DPlachkov commented 5 years ago

Hello.

I find this library amazing. I'm trying to convert currency to text, which for the language that i have chosen "bg" is not created, but thats ok - i can use the numbers convertor. I've checked the source code and there are 3 different forms .By default it is set to the neutral digit, but I need to use the masculine form. Is there some way to change it ?

 private static $digits = [
        0  => [1 => "едно", "две", "три", "четири", "пет", "шест", "седем", "осем", "девет"], // neuter
        1  => [1 => 'един', 'два'],                                                           // masculine
        -1 => [1 => 'една']                                                                   // feminine
    ];

The only code I use ( and this is an example ) is

$numberToWords =  new \NumberToWords\NumberToWords;
$trans = $numberToWords->getNumberTransformer('bg');
$trans->toWords(2011);

If there is no option to toggle this, is there a way for me to extend the library and do it on my own

tldr. i need to have "един" and "два" Instead of "едно" and "две".

kwn commented 5 years ago

Hey @DPlachkov

Thank you for reporting an issue. The code that you're referring to is inherited from the other library and may have some bugs. I believe the masculine, femine and neutral form were originally created for the currency translator (currencies in slavic languages have their "gender").

Can you provide a specific example you're trying to solve? Are you trying to transform something that needs to consider a gender form?