Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #4929 (closed defect: fixed)

Opened 2 years ago

Last modified 1 year ago

[PATCH] trivial problem of using an irregular plural form that does not start with the same letter as the singular

Reported by: norri_b@hotmail.com Assigned to: David
Priority: low Milestone:
Component: ActiveSupport Version: edge
Severity: trivial Keywords: verified
Cc: devslashnull@gmail.com

Description

When using an irregular plural form that does not start with the same letter as the singular form, Rails seems to change the first letter of the plural form to be the same as the singular form.

For example "inflect.irregular 'recipe', 'dishes'", Rails will attempt to map the model Recipe to a table called 'rishes'. It also calls it 'rishes' if you use the pluralize function in a view.

Attachments

irregular_first_char_plurals.diff (1.7 kB) - added by smeade on 01/13/07 22:30:29.
irregular_first_char_plurals.diff
cow_kine_test.diff (348 bytes) - added by smeade on 01/13/07 22:31:26.
cow_kine_test.diff
irregular_first_char_plurals_rev2.diff (2.2 kB) - added by josh on 02/23/07 21:18:36.
Merged patch + tests (r6216).

Change History

04/29/06 15:57:36 changed by devslashnull@gmail.com

  • cc set to devslashnull@gmail.com.

Haha, rishes... Do you actually know of a word whose plural starts with a different letter?

04/29/06 18:17:09 changed by norri_b@hotmail.com

Apparently, a genuine plural of cow is kine (see http://dictionary.reference.com/search?q=kine). Not that I can see anyone using kine in preference to cows.

01/13/07 18:20:05 changed by smeade

  • status changed from new to closed.
  • resolution set to worksforme.

if someone does find a word like this, they will put it in their environment.rb inflector rules as agreed in #5047

(follow-up: ↓ 7 ) 01/13/07 19:32:38 changed by hasmanyjosh

  • status changed from closed to reopened.
  • resolution deleted.

smeade: You're wrong there. The irregular inflections assume that the first letter is always the same. I agree it's a low priority fix, but it is actually a bug and not an issue with creating custom inflections in environment.rb. Setting an irregular for "cow" to "kine" gives these transformations:

[/(c)ow$/i, "\\1ine"] #plurals
[/(k)ine$/i, "\\1ow"] #singulars

Clearly that can't be fixed without changing how the inflector generates its regexps.

01/13/07 22:28:09 changed by smeade

patch for cow/kine - can't think of any other maybe other languages or proprietary systems have them ?? :)

01/13/07 22:30:29 changed by smeade

  • attachment irregular_first_char_plurals.diff added.

irregular_first_char_plurals.diff

01/13/07 22:31:02 changed by smeade

  • summary changed from Problem if using an irregular plural form that does not start with the same letter as the singular to [PATCH] trivial problem of using an irregular plural form that does not start with the same letter as the singular.

01/13/07 22:31:26 changed by smeade

  • attachment cow_kine_test.diff added.

cow_kine_test.diff

(in reply to: ↑ 4 ) 01/14/07 23:56:10 changed by smeade

Replying to hasmanyjosh:

smeade: You're wrong there. The irregular inflections assume that the first letter is always the same. I agree it's a low priority fix, but it is actually a bug and not an issue with creating custom inflections ...

Thanks for the catch. Of course you are right and I've submitted a patch to handle irregulars when first char is different, though I agree is low priority.

01/15/07 00:03:03 changed by smeade

comments: in the current (trunk) implementation, the first character is captured and reused in the regular expression as a way to ensure the proper case (upper/lower case) is retained. The trailing characters are always assumed to be lowercase by convention (actually would be whatever you put in the irregular definition).

examples:

>> "Person".pluralize  
=> "People"
>> "PERSON".pluralize  
=> "People"
>> "person".pluralize  
=> "people"
>> "pEOPLE".singularize
=> "person"

this patch follows the same convention of matching the first character to the case of the submitted string and the rest to the string to the case as defined in the irregular.

>> "Cow".pluralize
=> "Kine"
>> "COW".pluralize
=> "Kine"
>> "cow".pluralize
=> "kine"
>> "kINE".singularize
=> "cow"

02/23/07 21:18:36 changed by josh

  • attachment irregular_first_char_plurals_rev2.diff added.

Merged patch + tests (r6216).

02/23/07 21:18:52 changed by josh

  • keywords set to verified.
  • version changed from 1.1.1 to edge.

06/23/07 16:47:50 changed by david

  • status changed from reopened to closed.
  • resolution set to fixed.

(In [7092]) Added support for pluralization with a different starting letter than the singular version (cow/kine) (closes #4929) [norri_b/hasmanyjosh]