number_to_words_english 3.0.0
number_to_words_english: ^3.0.0 copied to clipboard
A comprehensive Flutter/Dart package that converts numbers to words with support for 12 languages including English, Vietnamese, Spanish, French, German, Italian, Portuguese, Russian, Chinese, Japanes [...]
ChangeLog #
3.0.0 - 2024-07-27 #
๐ Architecture Refactoring & Extension Methods + ๐ฅ Ordinal Numbers + ๐ฐ Currency Conversion #
๐๏ธ Modular Architecture
- Separated language implementations: Each language now has its own dedicated file
lib/src/languages/english.dart- English implementationlib/src/languages/vietnamese.dart- Vietnamese implementationlib/src/languages/spanish.dart- Spanish implementation
- Abstract base class:
NumberToWordsLanguageprovides common interface for all languages - Main API class:
NumberToWordsmanages all language implementations - Clean exports: Main library file exports all public APIs with proper documentation
โจ Extension Methods
num.toWords(): Convert any number to English words directly- Language-specific extensions:
num.toEnglish()- Convert to Englishnum.toVietnamese()- Convert to Vietnamesenum.toSpanish()- Convert to Spanishnum.toWordsInLanguage(String code)- Convert to any supported language
- Integer-specific extensions:
int.toCardinal()- Cardinal number conversionint.canConvertToWords()- Validation methodint.wordLength()- Get character count of word representationint.wordCount()- Get word count of representation
- Double-specific extensions:
double.toWordsWithDecimal()- Explicit decimal conversiondouble.integerPartToWords()- Convert only integer partdouble.decimalPartToWords()- Convert only decimal digits
- String extensions:
String.toWordsFromString()- Convert number strings to wordsString.isValidNumberString()- Validate number stringsString.toWordsInMultipleLanguages()- Convert to multiple languages at once
๐ง Advanced Features
- Dynamic language registration:
NumberToWords.registerLanguage() - Language introspection:
NumberToWords.getLanguageInfo() - Direct language access:
NumberToWords.getLanguage() - Runtime language management: Register/unregister languages dynamically
๐ฅ NEW: Ordinal Numbers Support
- Full ordinal support: Convert numbers to ordinal form (1st, 2nd, 3rd, etc.) in all 12 languages
- New API method:
NumberToWords.convertOrdinal(languageCode, number) - Complete extension methods:
toOrdinal(),toOrdinalVietnamese(),toOrdinalFrench(), etc. - Smart English ordinals: Proper irregular forms (first, second, third, eleventh, twelfth, twenty-first)
- Integer-specific methods:
toOrdinalWords(),getOrdinalSuffix(),canConvertToOrdinal() - Global coverage: All 12 languages support ordinal conversion with culturally appropriate forms
๐ฐ NEW: Currency Conversion Support
- 12 major currencies: USD, EUR, GBP, JPY, VND, CNY, KRW, THB, SGD, AUD, CAD, CHF
- New API method:
NumberToWords.convertCurrency(languageCode, amount, currencyCode) - Currency extension methods:
toCurrency(),toUSD(),toEUR(),toVND(),toCNY(), etc. - Multi-language currency names: Proper currency names in all 12 languages
- Subunit handling: Automatic cents, pence, xu, jiao, etc. for appropriate currencies
- No-decimal currencies: Special handling for JPY, KRW (no subunits)
- Smart plural forms: Proper singular/plural currency names (dollar vs dollars)
- Localized connectors: "and" (EN), "et" (FR), "y" (ES), "und" (DE), "ู" (AR), etc.
๐ Enhanced Documentation
- Comprehensive API documentation: Every method has detailed docs with examples
- Library-level documentation: Clear usage guide in main library file
- Migration guide: Step-by-step guide for upgrading from legacy API
- Interactive example app: Showcases all new extension methods and APIs
๐งช Comprehensive Testing
- 145 test cases: Complete coverage of all features including ordinals and currency
- 15 new ordinal tests: Dedicated coverage for all ordinal functionality
- 15 new currency tests: Complete currency conversion testing across all languages
- Extension method tests: Dedicated test groups for each extension type
- Architecture tests: Validation of modular design
- Edge case handling: Robust error handling and validation
๐ฑ Example App Enhancements #
- Extension methods demo: Interactive showcase of all extension methods
- ๐ Ordinal numbers demo: Real-time ordinal conversion in all 12 languages
- ๐ Currency conversion demo: Interactive currency conversion with all supported currencies
- Real-time examples: Dynamic code examples that update with user input
- Multi-API comparison: Side-by-side comparison of different APIs
- Smart UI: Ordinals only shown for positive integers, currency shown for all numbers
- Better UI: Modern Material Design 3 interface
๐ Backward Compatibility #
-
100% compatible: All existing code continues to work unchanged
-
Legacy API preserved:
NumberToWordsEnglishclass remains fully functional -
Smooth migration path: Clear examples showing old vs new API usage
-
Zero breaking changes: Existing code requires no modifications
-
Smooth migration: Old API redirects to new English implementation
๐๏ธ Architecture Improvements #
- Abstract base class:
NumberToWordsLanguagefor extensible language support - Modular design: Separate implementations for each language
- Performance optimized: Efficient number processing algorithms
- Well tested: 59 comprehensive test cases covering all languages
๐ Documentation & Examples #
- Updated README: Comprehensive multi-language examples and API documentation
- Example app: Interactive demo showcasing all supported languages
- Migration guide: Clear instructions for upgrading from legacy API
๐งช Testing #
- 59 test cases: Covering all languages, edge cases, and API compatibility
- Language-specific tests: Validation of number conversion rules for each language
- Backward compatibility tests: Ensures legacy API continues to function
2.1.0 #
- [new] Update support for large integers up to quintillion.
2.0.2 #
- fix ios build error
2.0.1 #
- fix formatting issues
0.0.3 #
- update changelog
0.0.2 #
- Readme fixes
0.0.1 #
- Initial release