| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This is a follow up to #4719. It appears that singularize and pluralize
are supposed to be idempotent - i.e. when you call singularize or
pluralize multiple times on the same string, you should get the same
result. (At least for the "officially supported" cases that the stock
inflector is designed to handle.) #4719 added the missing tests for
regular cases, and this commit added the missing tests for the
irregularities.
While I'm at that, I also synced up the irregularity test cases with
the current set of irregularity cases that we ship out-of-the-box.
|
|
|
|
|
|
|
|
| |
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.
|
|\
| |
| | |
Add Inflection test (and fixes) to ensure singularizing a singular actually give you the correct singular in more cases
|
| |
| |
| |
| | |
give you the correct singular in more cases
|
|/ |
|
| |
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
| |
This is also faster on 1.9.
|
|
|
|
| |
refactored common constantize tests into ConstantizeTestCases
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
|
| |
[#6490 state:committed]
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
|
|
|
|
|
|
| |
[#6363]
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
|
| |
|
|
|
|
| |
short inflections like ors do not affect larger words like sponsors [#6093 state:resolved]
|
|
|
|
| |
Signed-off-by: José Valim <jose.valim@gmail.com>
|
|
|
|
|
|
|
|
| |
'people'.pluralize should return 'people' not 'peoples'.
[#1183 state:committed]
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
|
|
|
| |
Signed-off-by: Yehuda Katz + Carl Lerche <ykatz+clerche@engineyard.com>
|
| |
|
|
|
|
|
|
| |
[#1489 state:resolved]
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
|
|
|
|
| |
[#1617 state:resolved]
|
| |
|
|
|
|
|
|
|
|
|
| |
(http://github.com/henrik/slugalizer)
Handles trailing and leading slashes, and squashes repeated separators into a single character.
Signed-off-by: Michael Koziarski <michael@koziarski.com>
[#1034 state:committed]
|
|
|
|
| |
Knuth".parameterize => "donald-e-knuth") #713 [Matt Darby]
|
|
|
|
| |
Signed-off-by: Tarmo Tänav <tarmo@itech.ee>
|
|
|
|
| |
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
|
|
|
|
| |
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
|
|
|
|
| |
ActiveSupport [#238 state:resolved]
|
| |
|
|
|
|
| |
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8563 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
|
|
|
|
| |
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7719 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
|
|
|
|
|
|
| |
can use them.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7655 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
|
|
|
|
|
|
| |
not "s" (closes #7720) [josh]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7569 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
|
|
|
|
|
|
| |
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
|
|
|
|
| |
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6886 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
|
|
|
|
| |
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6075 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
|
|
|
|
|
|
| |
Collins]. Remove unused code from Duration#inspect. Closes #7180. [Rich Collins]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6022 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
|
|
|
|
| |
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6019 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Check whether @flash is defined? for warnings-safety.
r4488@asus: jeremy | 2006-04-29 12:23:15 -0700
Check whether @flash is defined? for warnings-safety. Obviates nil? check.
r4489@asus: jeremy | 2006-04-29 12:45:18 -0700
Check whether @session is defined? for warnings-safety.
r4490@asus: jeremy | 2006-04-29 12:50:41 -0700
Check whether @rendering_runtime is defined? for warnings-safety.
r4491@asus: jeremy | 2006-04-29 12:55:01 -0700
Check whether @_cycles is defined? for warnings-safety.
r4492@asus: jeremy | 2006-04-29 12:59:19 -0700
Check whether instance variables are defined? for warnings-safety.
r4493@asus: jeremy | 2006-04-29 13:14:09 -0700
Add nil @template to PrototypeHelperTest to suppress unitialized instance variable warning.
r4494@asus: jeremy | 2006-04-29 13:31:34 -0700
Check whether @auto_index defined? for warnings-safety.
r4495@asus: jeremy | 2006-04-29 13:32:24 -0700
Wrap content_columns redefinitions with silence_warnings.
r4496@asus: jeremy | 2006-04-29 13:35:28 -0700
Wrap more redefinitions with silence_warnings.
r4829@asus: jeremy | 2006-07-08 10:59:20 -0700
abstract unit, fix warnings
r4830@asus: jeremy | 2006-07-08 11:06:12 -0700
Use parens to silence warning.
r4831@asus: jeremy | 2006-07-08 11:06:48 -0700
Use parens to silence warning.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4595 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
|
|
|
|
|
|
| |
Symbols. [Marcel Molina Jr.]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4359 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
|
|
|
|
|
|
| |
passing in :lower, like "super_man".camelize(:lower) # => "superMan" [DHH]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3986 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
|
|
|
|
|
|
| |
Inflector.dasherize)
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3877 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
|
|
|
|
|
|
| |
from basic structures [DHH] Moved Jim Weirich's wonderful Builder from Action Pack to Active Support (it's simply too useful to be stuck in AP) [DHH]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3812 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
|
|
|
|
| |
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3571 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
|