Coder Social home page Coder Social logo

Numeric Fallback about numbers_and_words HOT 5 OPEN

alethea avatar alethea commented on August 31, 2024
Numeric Fallback

from numbers_and_words.

Comments (5)

dblock avatar dblock commented on August 31, 2024

I am not sure. I think if the library can't convert something you'd probably want to get an error. At the very least that would be a change in behavior so we'd want a way to turn it off.

from numbers_and_words.

alethea avatar alethea commented on August 31, 2024

Oh, I'm so sorry, it looks like Github ate my description. I was suggesting it as an opt-in option. For instance, you're trying to render a page in the zh locale, it would fall back to numbers, but in en it would use words.

from numbers_and_words.

dblock avatar dblock commented on August 31, 2024

👍 give it a shot

from numbers_and_words.

jlduran avatar jlduran commented on August 31, 2024

@alethea Something like this?

require 'numbers_and_words'

number = 42
locales = %i(aa en es fr ru zh)

locales.each do |locale|
  begin
    I18n.with_locale(locale) { p number.to_words }
  rescue I18n::InvalidLocale
    p number
  end
end

# => 42
# => "forty-two"
# => "cuarenta y dos"
# => "quarante-deux"
# => "сорок два"
# => 42

from numbers_and_words.

alethea avatar alethea commented on August 31, 2024

@jlduran Yes, that's exactly the behavior I was proposing.

@dblock I'll see if I can put a PR together over the weekend.

from numbers_and_words.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.