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

name in currencyOptions not working #1178

Open
anil-suthar opened this issue Mar 13, 2023 · 4 comments
Open

name in currencyOptions not working #1178

anil-suthar opened this issue Mar 13, 2023 · 4 comments

Comments

@anil-suthar
Copy link

anil-suthar commented Mar 13, 2023

I tried below code, it works well but name config is not working. It always considers plural

{
    "localeCode": "en-IN",
    "converterOptions": {
        "currency": true,
        "currencyOptions": {
            "name": "Rupee",
            "plural": "Rupees",
            "symbol": "",
            "fractionalUnit": {
                "name": "Paisa",
                "plural": "Paise",
                "symbol": ""
            }
        }
    }
}

Test#1: 1.01 outputs One Rupees And One Paise Only but should be One Rupee And One Paisa Only
Test#2: 1.00 outputs One Rupees Only but should be One Rupee Only

Can you please check this or am I missing anything ?

@anil-suthar anil-suthar changed the title plural in currencyOptions not working name in currencyOptions not working Mar 14, 2023
@anil-suthar
Copy link
Author

Any chance to check this issue ? @mastermunj

@mastermunj
Copy link
Owner

@anil-suthar This seems like a breaking change. Will you be able to raise a PR for the same?

@anil-suthar
Copy link
Author

anil-suthar commented May 1, 2023

@mastermunj
I checked the code here : https://github.com/mastermunj/to-words/blob/main/dist/ToWords.js and I think you should replace the following code blocks :

Replace : (line# 161)

if (currencyOptions.plural) {
    words.push(currencyOptions.plural);
}

with

if (Number(split[0]) > 1 && currencyOptions.plural) {
    words.push(currencyOptions.plural);
} else {
    words.push(currencyOptions.name);
}

and Replace : (line# 180)

wordsWithDecimal.push(currencyOptions.fractionalUnit.plural);

with

if (Number(split[1]) > 1 && currencyOptions.fractionalUnit.plural) {
    wordsWithDecimal.push(currencyOptions.fractionalUnit.plural);
} else {
    wordsWithDecimal.push(currencyOptions.fractionalUnit.name);
}

@hardiksondagar
Copy link
Contributor

Hi @anil-suthar have a look at this #1470

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants