Ideas for v4, toCurrency, language codes... #265
Replies: 6 comments 2 replies
-
|
One thing that bugged me was the per-function web importing, but I eventually realized it would require another major ground-up refactor — splitting the language files into individual function/method files and sharing helpers across them. Definitely not impossible, but I felt the current language file size was good enough for release. Still something I'd like to revisit though. |
Beta Was this translation helpful? Give feedback.
-
Concerning language codes and currenciesCurrenciesIn my opinion, we must completely separate currencies from languages. Currencies apply to countries, not to languages. We should have a matrix of countries and their official currencies, their name in the country's official language, and in other languages. For example: the United Kingdom (country code: GB) has the currency Sterling (symbol: £; currency code: GBP). The country's main language is English (code: en). The currency name in English is With this matrix of countries/currencies names in the country language and other languages, an amount of money from any country can be expressed in any language. Language codesThe BCP 47 standard is composed of 2 documents:
Regarding language codes, we should prefer generic tags like en/fr/ar. They are totally correct BCP 47 tags. The differences between countries are minor and don't justify making the region/country code mandatory. Moreover, we should not consider variants of a language (en-GB, en-US...) as different languages. For example, English is an official language in ~60 countries; we could not claim that we support ~60 more languages. The same applies to all major languages like French, Spanish and Arabic. (NB: I saw some similar libraries inflating the number of supported languages by counting variants). |
Beta Was this translation helpful? Give feedback.
-
|
Thanks for the thoughtful write-up on this — always appreciate you taking the time to think through the design. On currenciesI see the appeal of a country/currency/language matrix, but I think it's solving a real problem with too heavy an abstraction. Currency naming is inherently linguistic — how you pluralize "dollar," where you place the amount, how you join dollars and cents — that's all grammar, not geography. Building a full CLDR-style matrix is well outside the scope of what n2words should be. For the cross-locale case (e.g. expressing GBP in French), I think that's better handled as an optional currency override rather than a fundamental redesign. On language codesI agree that bare tags like And that precision matters here. Regional variants aren't cosmetic — That said, supporting bare tags like |
Beta Was this translation helpful? Give feedback.
-
|
Thank you too for the ideas. On currencies, I agree that handling all languages is overkill (or maybe not — probably it's one prompt away :D) and indeed we must focus on the country's main language. On language codes, we may consider a mix:
What do you think @TylerVigario ? |
Beta Was this translation helpful? Give feedback.
-
|
I like the tiered approach in theory, but I think it has a fundamental blind spot: none of the tiers account for Tier 1 ( Tier 2 ( Tier 3 ( So across all three tiers, the region is required for I think we're going in circles a bit here — every shortcut we look at runs into the same wall. The region code is the region code because it encodes information we actually need. On the duplication side though, totally agree that's worth addressing with shared internals between variants. |
Beta Was this translation helpful? Give feedback.
-
|
First, a clarification: the 3 options I suggested apply only to cardinal and ordinal functions, not to currencies. I'd like to emphasise a fundamental point: currencies must be handled separately from cardinal/ordinal functions. Unlike cardinal/ordinal, which depend only on a language in most of the cases, currencies depend on both a country and a language. Having a distinct API for Let's remember that the core purpose of n2words is to convert numbers to words. With that in mind, I have doubts about the relevance of adding currency support to the package at all. It's a nice-to-have feature, but it's more of a convenience function that uses n2words capabilities rather than a core feature. It should not drive the design of the main API. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm creating this discussion for brainstorming ideas and designing the future v4 of n2words.
Main features:
Refs: #228, #261 (comment)
Beta Was this translation helpful? Give feedback.
All reactions