Git Product home page Git Product logo

Comments (4)

bensheldon avatar bensheldon commented on June 2, 2024

Thanks for opening this issue! I'll add a zero onto those keys.

from good_job.

bensheldon avatar bensheldon commented on June 2, 2024

hmmm, I'm having trouble reproducing this. Those helpers don't require a zero for me, so I'm a little confused about why your setup would 🤔

Screenshot 2023-06-28 at 7 19 57 AM

from good_job.

bensheldon avatar bensheldon commented on June 2, 2024

Doing a little research, it seems like the i18n gem asserts pluralize "...will pick the :zero subkey in the special case where count is equal to 0 and there is a :zero subkey present."

https://github.com/ruby-i18n/i18n/blob/7cf09474b77fd41e65d979134b0525f67cf371b0/lib/i18n/backend/base.rb#L168-L170

Which matches up with the code:

https://github.com/ruby-i18n/i18n/blob/7cf09474b77fd41e65d979134b0525f67cf371b0/lib/i18n/backend/pluralization.rb#L48

😕 So I'm not sure why your application is specifically expecting a zero key. Are there other I18n-related gems that you're using or something that has been patched into your application?

Edit: this also matches up with the Rails translation docs too: https://guides.rubyonrails.org/i18n.html#pluralization

The translation denoted as :one is regarded as singular, and the :other is used as plural. If the count is zero, and a :zero entry is present, then it will be used instead of :other.

from good_job.

Roko131 avatar Roko131 commented on June 2, 2024

You are correct, it is specifically related to my application configuration- my bad.

This is the culprit:
config/locales/plurals.rb:

{:en =>
  { :i18n =>
    { :plural =>
      { :keys => [:zero, :one, :other],
        :rule => lambda { |n|
          if n == 1
            :one
          elsif n == 0
            :zero
          else
            :other
          end
        }
      }
    }
  }
}

from good_job.

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.