khmer_intl 0.1.0
khmer_intl: ^0.1.0 copied to clipboard
Khmer (km) internationalization helpers for Flutter/Dart: Khmer digits, date, currency and locale utilities.
khmer_intl #
Khmer (km) internationalization helpers for Dart and Flutter.
khmer_intl gives you Khmer-friendly formatting utilities for digits, numbers, currency, dates, relative time, plural selection, and an approximate lunar date model.
Preview #
[Preview 1] [Preview 2]
Features #
- Latin digit -> Khmer digit conversion (
123->១២៣) - Khmer digit -> Latin digit conversion
- Number formatting and KHR currency formatting (
៛) - Compact number formatting (e.g.
1.3លាន) - Percent formatting
- Khmer date formatting with month/weekday names
- Buddhist Era year option (
AD + 543) - Date preset constructors (
shortDate,mediumDate,fullDate,fullDateTime) - Khmer relative time (e.g.
២ ម៉ោងមុន) - Simple plural helper
- Approximate Khmer lunar date model
- Extension methods for
int,num,String, andDateTime
Installation #
dependencies:
khmer_intl: ^0.1.0
Then run:
dart pub get
or (Flutter):
flutter pub get
Quick Start #
import 'package:khmer_intl/khmer_intl.dart';
Digits #
toKhmerDigits('1234567890');
// ១២៣៤៥៦៧៨៩០
'២០២៦'.toLatinDigits();
// 2026
Number and Currency #
2500.toKhmerCurrency(useKhmerDigits: true);
// ៛២,៥០០
1250000.toKhmerCompact(useKhmerDigits: true);
// ១.៣លាន
0.275.toKhmerPercent(useKhmerDigits: true, fractionDigits: 1);
// ២៧.៥%
Date Formatting #
final date = DateTime(2026, 4, 14);
KhmerDateFormat('EEE dd MMMM yyyy', buddhistEra: true, useKhmerDigits: true)
.format(date);
// អង្គារ ១៤ ខែមេសា ២៥៦៩
KhmerDateFormat.fullDate(buddhistEra: true, useKhmerDigits: true).format(date);
KhmerDateFormat.fullDateTime(useKhmerDigits: true).format(DateTime.now());
Relative Time #
final now = DateTime.now();
final past = now.subtract(const Duration(hours: 2));
past.toKhmerRelativeTime(reference: now, useKhmerDigits: true);
// ២ ម៉ោងមុន
Plural Helper #
khmerPlural(
2,
one: 'មានទំនិញ 1 មុខ',
other: 'មានទំនិញ 2 មុខ',
);
Lunar Date (Approximate) #
final lunar = KhmerLunarDate.fromGregorian(DateTime.now());
print(lunar);
Core APIs #
Top-level functions #
toKhmerDigits(String input)toLatinDigits(String input)khmerPlural(num count, {required String one, required String other})
Formatters #
KhmerNumberFormat.decimal(...)KhmerNumberFormat.currencyKHR(...)KhmerCompactNumberFormat(...)KhmerPercentFormat(...)KhmerDateFormat(pattern, ...)KhmerDateFormat.shortDate(...)KhmerDateFormat.mediumDate(...)KhmerDateFormat.fullDate(...)KhmerDateFormat.fullDateTime(...)KhmerRelativeTime.format(...)
Extensions #
int.toKhmerDigits()String.toKhmerDigits()String.toLatinDigits()num.toKhmerCurrency(...)num.toKhmerCompact(...)num.toKhmerPercent(...)DateTime.toKhmerDate(...)DateTime.toKhmerRelativeTime(...)
Flutter LocalizationsDelegate #
A working Khmer LocalizationsDelegate example is included in:
example/lib/khmer_localizations.dartexample/lib/main.dart
Notes #
- Khmer lunar support is currently approximate (starter implementation).
- Compact/percent styles are designed to be practical and lightweight.
Testing #
dart test
License #
MIT
Sponsor Me #
If you find my projects helpful and want to support my work, you can sponsor me! 💖