marick
I’d like to print “zero reservations”, “one reservation”, “two reservations”, etc. I can use inflex to get plurals and singulars, but I can’t find anything that’s the equivalent of Ruby’s to_words or humanize gems. Neither inflex nor Number has what I want:
to_word(1) # "one"
Am I missing something? Were I to port one of the Ruby libraries, is there an Elixir library to target for a pull request?
Trending in Questions
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
apply_graft/2 doesn’t rewrite an add_many sub-workflow’s deps on an add step. Grafted jobs cancel with “upstream job was deleted”
Version...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming











Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
aenglisc
https://github.com/elixir-cldr/cldr
kip
Thanks for the shoutout. The package on hex is ex_cldr_numbers (I am the author). Some examples from the readme:
Formatting numbers as words, ordinals and roman numerals
:spelloutand:spellout_verbose.:spellout_year.:ordinal,:spellout_ordinaland:spellout_ordinal_verbose.:romanor:roman_lower. Note that roman number formatting is only supported for numbers between 1 and 5,000.dimitarvp
I keep being impressed by the high quality of your work. Extremely well done.
jawbean.05
Hello how about with decimal amount, can convert to word?
kip
Yes.
ex_cldrand friends support integers, floats and Decimals.joaquinalcerro
Hello everyone,
Is it me or the to_string function does not support decimals?
If this is the case, can someone explain why? Is there any way to make it work?
Best regards,
kip
Rules based number formats are curious things and the default
:spellout_numberingrule (which is what you get withformat: :spelloutdoesn’t support fractional digits. I suspect that it’s because most (maybe all?) locales support:spellout_numberingbut not all locales have the notion of spelling out the fractional part.However all is not lost, there are other rule sets. You can see what rule sets exist for a given locale with:
And if you try
:spellout_cardinaland:spellout_cardinal_verboseyou’ll see:joaquinalcerro
Thanks @kip,
I hope I had found this library when starting my project.
Tried your solution and worked for locale “en” but not for “es”.
Still, this is of great help. I am going to create a small function to separate the decimals and create a new string out of it.
Best regards,
kip
@joaquinalcerro, not all locales have the same RBNF (rules based number formats) rules. That’s why it’s important to check first what rules are available. For
:es:As you can see there is no
:spellout_cardinalbut there are:spellout_cardinal_masculineand:spellout_cardinal_feminine. Lets try those:Note: Requires the latest
ex_cldr_numbersversion 2.32.2.joaquinalcerro
Thanks @kip for the detailed explanation.
This will work perfectly for my use case.
Best regards