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

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;
}
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

1 participant