Skip to content
New issue

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

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

Already on GitHub? # to your account

Nepali currency in words #10

Open
roopaish opened this issue Jul 27, 2023 · 0 comments
Open

Nepali currency in words #10

roopaish opened this issue Jul 27, 2023 · 0 comments

Comments

@roopaish
Copy link

roopaish commented Jul 27, 2023

Instead of

print('123456 -> ${inWords.format(123456)}');
// 123456 -> 1 lakh 23 thousand 4 hundred 56

Can we have

print('123456 -> ${inWords.format(123456)}');
// 123456 -> one lakh twenty three thousand four hundred fifty six

I didn't find a way in this library to do this.

I ended up using this package with intl package like this

String amountToNepaliWords(double value) {
  // Format the number to Nepali words
  NepaliNumberFormat nepaliNumberFormat = NepaliNumberFormat(
    inWords: true,
    decimalDigits: 2,
    isMonetory: true,
    includeDecimalIfZero: false,
  );

  String formattedAmount = nepaliNumberFormat.format(value);

  // Convert formatted number to letters
  String amountInLetters = formattedAmount.replaceAllMapped(
    RegExp(r'\d+'),
    (match) => NumberToWordsEnglish.convert(int.parse(match.group(0)!)),
  );

  return amountInLetters;
}
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant