Add Brazilian Portuguese (pt-BR) support#275
Open
roperes98 wants to merge 2 commits intoforzagreen:mainfrom
Open
Add Brazilian Portuguese (pt-BR) support#275roperes98 wants to merge 2 commits intoforzagreen:mainfrom
roperes98 wants to merge 2 commits intoforzagreen:mainfrom
Conversation
Collaborator
|
Hey @roperes98, thanks for the pt-BR contribution — the implementation looks solid! A couple of things are missing before we can merge:
I've got the scaffold ready on my end — I can push it to your branch if you'd like, or you can run Let me know how you'd like to proceed! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📌 Pull Request: Add Brazilian Portuguese (pt-BR) support
✨ Summary
This PR adds full support for Brazilian Portuguese (
pt-BR) to the library, including:The implementation follows Brazilian Portuguese linguistic rules and CLDR conventions.
🇧🇷 Features
🔢 Cardinal numbers
Correct use of conjunction "e" between hundreds, tens, and units
cento e vinte e trêsProper handling of:
"cem"(exact 100)"cento"(100+ remainder)Omission of
"um"before"mil"mil(not um mil)Support for large numbers using short scale:
🔟 Ordinal numbers
Full ordinal support with proper composition:
primeiro,décimo segundo,centésimo, etc.Scalable to large numbers using ordinal scale forms:
milésimo,milionésimo, etc.💰 Currency (BRL)
Converts values to Brazilian Real format:
1→um real2.50→dois reais e cinquenta centavosHandles pluralization correctly:
real/reaiscentavo/centavosOptional
"e"conjunction between reais and centavos⚙️ Implementation details
Uses BigInt-based segmentation for efficient large number handling
Modular structure aligned with existing parsers:
parseCardinalValueparseOrdinalValueparseCurrencyValueOptimized fast paths for:
< 1000< 1,000,000Precomputed scale words (singular and plural)
🧠 Language-specific rules covered
Conjunction rules with
"e"Irregular hundreds:
duzentos,trezentos,quinhentos, etc.Decimal separator:
"vírgula"Negative numbers:
"menos"✅ Examples
🚀 Notes