aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/inflections.rb
Commit message (Collapse)AuthorAgeFilesLines
* Make ActiveSupport::Inflector locale aware and multilingualDavid Celis2012-07-301-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The Inflector is currently not very supportive of internationalized websites. If a user wants to singularize and/or pluralize words based on any locale other than English, they must define each case in locale files. Rather than create large locale files with mappings between singular and plural words, why not allow the Inflector to accept a locale? This patch makes ActiveSupport::Inflector locale aware and uses `:en`` unless otherwise specified. Users will still be provided a list of English (:en) inflections, but they may additionally define inflection rules for other locales. Each list is kept separately and permanently. There is no reason to limit users to one list of inflections: ActiveSupport::Inflector.inflections(:es) do |inflect| inflect.plural(/$/, 's') inflect.plural(/([^aeéiou])$/i, '\1es') inflect.plural(/([aeiou]s)$/i, '\1') inflect.plural(/z$/i, 'ces') inflect.plural(/á([sn])$/i, 'a\1es') inflect.plural(/é([sn])$/i, 'e\1es') inflect.plural(/í([sn])$/i, 'i\1es') inflect.plural(/ó([sn])$/i, 'o\1es') inflect.plural(/ú([sn])$/i, 'u\1es') inflect.singular(/s$/, '') inflect.singular(/es$/, '') inflect.irregular('el', 'los') end 'ley'.pluralize(:es) # => "leyes" 'ley'.pluralize(:en) # => "leys" 'avión'.pluralize(:es) # => "aviones" 'avión'.pluralize(:en) # => "avións" A multilingual Inflector should be of use to anybody that is tasked with internationalizing their Rails application. Signed-off-by: David Celis <david@davidcelis.com>
* make sure the inflection rules are loaded when cherry-picking ↵Xavier Noria2012-06-291-0/+2
| | | | active_support/core_ext/string/inflections.rb [fixes #6884]
* Fix an issue with inflection where my_analyses (in plular form) incorrectly ↵Anuj Dutta2012-05-161-1/+1
| | | | converted to my_analyasis(in singular form).
* fix inflector bug where -ice gets pluralized into -ouseWes Morgan2012-02-251-4/+4
| | | | This should happen for mouse or louse, but not slice or pumice.
* fixes a regression introduced by 532cd4, and a bogus test in AP the ↵Xavier Noria2012-02-101-2/+3
| | | | regression uncovered
* Add Inflection test (and fixes) to ensure singularizing a singular actually ↵Mark McSpadden2012-01-271-6/+7
| | | | give you the correct singular in more cases
* Fix inflection regexes for mouse, miceMark Rushakoff2011-12-071-3/+3
|
* Added irregular zombie inflection, so zombies no longer gets singularized ↵Gregg Pollack2011-08-071-0/+1
| | | | into zomby
* handle double pluralization for irregular pluralsDan Pickett2011-02-161-0/+4
| | | | | | [#6363] Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
* Changed the way inflections for uncountables work for 'funky jeans' [#3576 ↵Rolf Bjaanes2010-04-051-1/+1
| | | | | | state:resolved] Signed-off-by: José Valim <jose.valim@gmail.com>
* Adding inflection of databases (usually we wouldn't amend the current ↵Jiri Zajpt2009-02-121-0/+1
| | | | | | defaults, but this seems to obvious) [#1942 state:committed] Signed-off-by: David Heinemeier Hansson <david@loudthinking.com>
* Namespace Inflector, Dependencies, OrderedOptions, and TimeZone under ↵Joshua Peek2008-06-031-49/+51
| | | | ActiveSupport [#238 state:resolved]
* Added support for pluralization with a different starting letter than the ↵David Heinemeier Hansson2007-06-231-0/+1
| | | | | | singular version (cow/kine) (closes #4929) [norri_b/hasmanyjosh] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7092 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Inflections: MatrixTest -> MatrixTests instead of MatricesTest. Closes #8496.Jeremy Kemper2007-05-291-1/+1
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6886 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Inflections: don't singularize -ies plurals.Jeremy Kemper2006-08-301-1/+0
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4868 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Remove unnecessary brackets in regex (closes #5715)David Heinemeier Hansson2006-08-051-1/+1
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4668 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* r3214@asus: jeremy | 2005-11-20 02:03:05 -0800Jeremy Kemper2005-11-211-48/+48
| | | | | | | Parenthesize args in Inflections git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3126 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Fix status pluralization bug so status_codes doesn't get pluralized as ↵Jeremy Kemper2005-11-071-2/+2
| | | | | | statuses_code. Closes #2758. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2900 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Fixed inflections for status, quiz, move #2056 [deirdre@deirdre.net]David Heinemeier Hansson2005-09-121-4/+6
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2214 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Added irregular inflection sex => sexes #1826 [rails@electricvisions.com]David Heinemeier Hansson2005-09-111-0/+1
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2200 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* You will never sleep again!David Heinemeier Hansson2005-09-031-1/+1
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2113 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Added String#at, String#from, String#to, String#first, String#last in ↵David Heinemeier Hansson2005-09-031-0/+50
ActiveSupport::CoreExtensions::String::Access to ease access to individual characters and substrings in a string serving basically as human names for range access. Added easy extendability to the inflector through Inflector.inflections (using the Inflector::Inflections singleton class) git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2110 5ecf4fe2-1ee6-0310-87b1-e25e094e27de