Git Product home page Git Product logo

inflections's Introduction

Inflections Build Status

Inflections is a repository containing non-English singularization and pluralization rules for Rails, supporting the multilingual ActiveSupport::Inflector in Rails 4.

Languages Currently Supported

  • Spanish (es)
  • French (fr)
  • Kazakh (kk)
  • Norwegian Bokmål (nb)
  • Turkish (tr)

If you are fluent in a language not yet included in this gem, please consider creating a list of inflections and submitting a pull request.

Installation

Add the following to your application's Gemfile:

gem 'inflections'

And then execute:

$ bundle

Usage

To inflect strings in a different locale:

'persona'.pluralize(:es)
# => "personas"
'madame'.pluralze(:fr)
# => "mesdames"

Define your own additional rules as such:

ActiveSupport::Inflector.inflections(:en) do |inflect|
  inflect.singular /(phase)s$/i, '\1'
  inflect.plural /(shel|kni)fe/, '\1ves'
  inflect.irregular 'foot', 'feet'
  inflect.uncountable %w[money fish]
end

Rails < 4.0.0

If you're not using ActiveSupport 4, the multilingual Inflector won't be supported. You should install inflections 3.2.x and you'll have to choose which locale you use by requiring a specific file:

gem 'inflections', '~> 3.2', require: 'inflections/es'

Note that this will override the default set of English rules that come with Rails. You should do this only if you plan on your constants and code itself not being in English.

Contributing

Please note that pull requests for already supported languages will only be accepted for rules that are in error or a potentially missed rule. If your change is an exception to an existing rule, that exception must occur frequently and must involve words used more frequently than the regular plurals. If your change is an irregularity, it must be a word that is arguably frequently encountered in applications that would use ActiveSupport. The default list of inflections is meant to be short.

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature') with tests
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

inflections's People

Contributors

davidcelis avatar ferhatelmas avatar redcapital avatar sarahhodne avatar mauriciopasquier avatar lwe avatar

Watchers

James Cloos avatar  avatar

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.