ethiopian_birr 0.1.0 copy "ethiopian_birr: ^0.1.0" to clipboard
ethiopian_birr: ^0.1.0 copied to clipboard

Format Ethiopian Birr in Amharic and Latin script, including Amharic amount-in-words, Ge'ez numerals, and ETB string parsing. Pure Dart, zero dependencies.

example/main.dart

// Prints a single invoice line the way it might appear on an Ethiopian
// receipt, contract, or cheque — the headline reason to reach for this
// package: Amharic amount-in-words, alongside Latin/Amharic/Ge'ez currency
// formatting, santim splitting, and round-trip parsing.
import 'package:ethiopian_birr/ethiopian_birr.dart';

void main() {
  const amountDue = 1234.56;

  _line('Invoice #1042', '');
  _line('Amount due (Latin):', Birr.format(amountDue));
  _line(
    'Amount due (Amharic):',
    Birr.format(amountDue, format: BirrFormat.amharic),
  );
  _line('Amount in words:', Birr.toWords(amountDue));

  final (birr, santim) = Birr.split(amountDue);
  _line('Birr / santim:', '$birr birr, $santim santim');

  // Ge'ez numerals for the whole-birr part of a round amount, e.g. for a
  // manuscript-style page or chapter reference rather than a receipt total.
  const roundAmount = 1234;
  _line(
    "Ge'ez numerals ($roundAmount):",
    Birr.format(roundAmount, format: BirrFormat.geez),
  );

  // Round-trip: parse a formatted string back into a number.
  final formatted = Birr.format(amountDue);
  _line('Round-tripped "$formatted":', '${Birr.parse(formatted)}');

  // Ergonomic num extensions, for inline call sites.
  _line(
    'Extension methods:',
    '${amountDue.toBirr()} / ${amountDue.toBirrWords()}',
  );
}

void _line(String label, String value) {
  if (value.isEmpty) {
    print(label);
    return;
  }
  final padded = label.length < 26 ? label.padRight(26) : '$label ';
  print('$padded$value');
}
2
likes
160
points
37
downloads

Documentation

API reference

Publisher

verified publisherbinimuse.com

Weekly Downloads

Format Ethiopian Birr in Amharic and Latin script, including Amharic amount-in-words, Ge'ez numerals, and ETB string parsing. Pure Dart, zero dependencies.

Repository (GitHub)
View/report issues

Topics

#ethiopia #currency #birr #amharic #i18n

License

MIT (license)

More

Packages that depend on ethiopian_birr