Commit message (Collapse) | Author | Age | Files | Lines | |
---|---|---|---|---|---|
* | Make ActiveSupport::Inflector locale aware and multilingual | David Celis | 2012-07-30 | 1 | -9/+14 |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 Noria | 2012-06-29 | 1 | -0/+2 |
| | | | | active_support/core_ext/string/inflections.rb [fixes #6884] | ||||
* | removing unnecessary 'examples' noise from activesupport | Francesco Rodriguez | 2012-05-13 | 1 | -8/+1 |
| | |||||
* | decouples the implementation of the inflector from its test suite | Xavier Noria | 2012-02-24 | 1 | -0/+7 |
| | | | | | | | | Trying alternative implementations of the inflections is hard because the suite is coupled with the current one, setting ivars by hand etc. This commit relies on initialize_dup, as long as you maintain that one you can tweak the implementation. | ||||
* | say unshift when you mean unshift (modulus prepend) | Xavier Noria | 2012-02-11 | 1 | -3/+5 |
| | |||||
* | Add acronym support to Inflector; Issue #1366 | David Lee | 2011-06-11 | 1 | -3/+4 |
| | |||||
* | Refactor | David Lee | 2011-06-11 | 1 | -91/+51 |
| | |||||
* | proper reset all inflector scopes | Stefan Huber | 2011-04-25 | 1 | -1/+1 |
| | |||||
* | Added a word boundary to uncountable inflection regex for #singularize so ↵ | John Paul Ashenfelter | 2010-12-22 | 1 | -1/+1 |
| | | | | short inflections like ors do not affect larger words like sponsors [#6093 state:resolved] | ||||
* | Changed the way inflections for uncountables work for 'funky jeans' [#3576 ↵ | Rolf Bjaanes | 2010-04-05 | 1 | -1/+1 |
| | | | | | | state:resolved] Signed-off-by: José Valim <jose.valim@gmail.com> | ||||
* | Remove string access core extension dependency | Jeremy Kemper | 2009-11-09 | 1 | -3/+1 |
| | |||||
* | Break up inflector to reduce the dependency burden on dependency-les methods ↵ | Yehuda Katz | 2009-11-07 | 1 | -0/+213 |
like constantize. |