Commit message (Collapse) | Author | Age | Files | Lines | |
---|---|---|---|---|---|
* | Make ActiveSupport::Inflector locale aware and multilingual | David Celis | 2012-07-30 | 2 | -15/+30 |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 | 2 | -0/+3 |
| | | | | active_support/core_ext/string/inflections.rb [fixes #6884] | ||||
* | Fix warning: shadowing outer local variable - constant. | kennyj | 2012-05-19 | 1 | -3/+3 |
| | |||||
* | Handle case where ancestor is not the end of the chain | Andrew White | 2012-05-19 | 1 | -7/+12 |
| | |||||
* | Fix constantize so top level constants are looked up properly. | Marc-Andre Lafortune | 2012-05-19 | 1 | -1/+1 |
| | |||||
* | Make constantize look down the ancestor chain (excluding Object) | Marc-Andre Lafortune | 2012-05-19 | 1 | -1/+13 |
| | |||||
* | Revert "Merge pull request #6354 from lest/patch-1" | Carlos Galdino + Rafael Mendonça França | 2012-05-16 | 1 | -1/+1 |
| | | | | | | | This reverts commit e8feaff60b9c04d34ad234f7d17b5d2ad9cc7a24, reversing changes made to 9adf28c026070afb78b80027521a4ddddd68d697. Reason: This broke the actionmailer tests | ||||
* | remove unnecessary require | Sergey Nartimov | 2012-05-16 | 1 | -1/+1 |
| | | | | | - access & filters don't use multibyte ext - transliterate requires only AS::Multibyte but not multibyte ext | ||||
* | removing unnecessary 'examples' noise from activesupport | Francesco Rodriguez | 2012-05-13 | 3 | -23/+1 |
| | |||||
* | fix typo in ActiveSupport::Inflector#titleize | Francesco Rodriguez | 2012-04-28 | 1 | -1/+1 |
| | |||||
* | revises the regexp used in titleize | Xavier Noria | 2012-04-07 | 1 | -1/+1 |
| | | | | | | | | | The regexp used in titleize matches saxon genitive and other contractions, only to call capitalize on the captured text and have the apostrophe upcased which yields the apostrophe itself. It is more clear that the regexp matches just what it has to match. | ||||
* | Updated/changed useless tr/gsubs | Jurriaan Pruis | 2012-04-03 | 1 | -1/+1 |
| | |||||
* | Fix typo | Artyom Bolshakov | 2012-04-03 | 1 | -1/+1 |
| | |||||
* | String#titleize works properly with smart quotes, closes #5584 | Vasiliy Ermolovich | 2012-03-26 | 1 | -2/+4 |
| | |||||
* | Inflector/constantize - inject method lets us to avoid using another variable | homa | 2012-02-28 | 1 | -5/+3 |
| | |||||
* | 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. | ||||
* | prefer tr to gsub for replacing characters | Xavier Noria | 2012-02-12 | 1 | -2/+2 |
| | |||||
* | inflection regexp are meant to be applied once | Xavier Noria | 2012-02-12 | 1 | -2/+2 |
| | |||||
* | removes redundant argument | Xavier Noria | 2012-02-12 | 1 | -1/+1 |
| | |||||
* | boosts inflections | Xavier Noria | 2012-02-12 | 1 | -1/+1 |
| | | | | | The impact of this change has been measured pluralizing the entire /usr/share/dict/words, showing a 6x speedup | ||||
* | say unshift when you mean unshift (modulus prepend) | Xavier Noria | 2012-02-11 | 1 | -3/+5 |
| | |||||
* | Add ActiveSupport::Inflector.ordinal and Integer#ordinal | Tim Gildea | 2012-02-04 | 1 | -10/+24 |
| | |||||
* | There is an "inherit" option on const_get too, why not use it? | Semyon Perepelitsa | 2012-01-31 | 1 | -1/+1 |
| | |||||
* | safe_constantize should handle wrong constant name NameErrors Fixes #4710 | Alex Tambellini | 2012-01-26 | 1 | -1/+1 |
| | |||||
* | global variables may not be set depending on the match. fixes #4703 | Aaron Patterson | 2012-01-26 | 1 | -1/+4 |
| | |||||
* | Change ActiveRecord::Errors to ActiveModel::Errors in guides | Carlos Antonio da Silva | 2012-01-25 | 1 | -6/+6 |
| | | | | | | | Use ActiveModel::Errors in inflection example docs as well. Also fixes wrong information and link to locale file related to Errors#full_messages in I18n guide. | ||||
* | remove ruby 1.8 checking in constantize method | Vasiliy Ermolovich | 2011-12-29 | 1 | -39/+24 |
| | |||||
* | fix typo again (Thanks Phillip Oertel) | Vijay Dev | 2011-11-08 | 1 | -1/+1 |
| | |||||
* | fix typo | Vijay Dev | 2011-11-06 | 1 | -1/+1 |
| | |||||
* | Refactored pluralize and singularize into a common method. | Henrik Hodne | 2011-11-06 | 1 | -16/+18 |
| | | | | See diff discussion on rails/#3536. | ||||
* | defines Module#qualified_const_(defined?|get|set) and String#deconstantize | Xavier Noria | 2011-10-29 | 1 | -6/+23 |
| | | | | | | | | | | This commit also implements a faster version of #demodulize I was unable to isolate with git add --patch. Not a big fan of the name #deconstantize. It complements #demodulize getting rid of the rightmost constant, hence the name, but it is unrelated to the well-known #constantize. So unsure. Could not come with anything better, please feel free to rename. | ||||
* | let demodulize do less work, and add tests | Xavier Noria | 2011-10-29 | 1 | -1/+3 |
| | | | | This is also faster on 1.9. | ||||
* | Update CHANGELOG for safe_constantize. | José Valim | 2011-09-23 | 1 | -1/+4 |
| | |||||
* | Ensure that constantize just rescues NameError that applies to the constant ↵ | José Valim | 2011-09-23 | 1 | -4/+20 |
| | | | | being currently loaded. | ||||
* | Added ActiveSupport::Inflector.safe_constantize and String#safe_constantize; ↵ | Ryan Oblak | 2011-09-23 | 1 | -0/+27 |
| | | | | refactored common constantize tests into ConstantizeTestCases | ||||
* | Revert removing gsub and sub from safe buffer. | José Valim | 2011-09-08 | 1 | -24/+8 |
| | |||||
* | remove support of symbols on classify and camelize | Damien Mathieu | 2011-09-08 | 1 | -0/+16 |
| | |||||
* | make gsub and sub unavailable in SafeBuffers - Closes #1555 | Damien Mathieu | 2011-09-08 | 1 | -8/+8 |
| | |||||
* | Add more examples to #titleize | Pol Llovet | 2011-07-09 | 1 | -2/+4 |
| | |||||
* | Add acronym support to Inflector; Issue #1366 | David Lee | 2011-06-11 | 2 | -10/+14 |
| | |||||
* | Refactor | David Lee | 2011-06-11 | 2 | -91/+143 |
| | |||||
* | adds code examples for negative ordinalize | Vijay Dev | 2011-05-08 | 1 | -1/+3 |
| | |||||
* | ordinalize negative numbers patch | Jason | 2011-05-07 | 1 | -2/+2 |
| | | | | | | | Applied patch by Amir Manji https://github.com/rails/rails/issues/437#issuecomment-1116045 Signed-off-by: Jason <jasonmichaelroth@gmail.com> | ||||
* | 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] | ||||
* | require i18n in transliterate so it can run in isolated situations | Jack Dempsey | 2010-09-14 | 1 | -0/+1 |
| | |||||
* | camelize and underscore are sort of inverse of each other, but not in a ↵ | Xavier Noria | 2010-07-22 | 1 | -1/+11 |
| | | | | mathematical sense [#5174 state:resolved] | ||||
* | Use multibyte proxy class on 1.9, refactor Unicode. | Norman Clarke | 2010-05-21 | 1 | -2/+3 |
| | | | | | | | | | | Makes String#mb_chars on Ruby 1.9 return an instance of ActiveSupport::Multibyte::Chars to work around 1.9's lack of Unicode case folding. Refactors class methods from ActiveSupport::Multibyte::Chars into new Unicode module, adding other related functionality for consistency. [#4594 state:resolved] Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net> | ||||
* | fixes colon in previous YAML example | Xavier Noria | 2010-05-03 | 1 | -1/+1 |
| | |||||
* | Fix transliteration rule example in docs. [#4526 state:resolved] | Norman Clarke | 2010-05-03 | 1 | -2/+3 |
| | | | | Signed-off-by: Xavier Noria <fxn@hashref.com> |