This project is archived and is in readonly mode.

#2566 ✓invalid
Troy

Add "a"/"an" inflector - indefinitize()

Reported by Troy | April 26th, 2009 @ 08:51 PM | in 2.x

Wanted to display "a listing" instead of "an listing", and "an Article" instead of "a Article". Patch adds indefinitize() inflector, which prepends the correct indefinite article based on first letter (vowel or consonant). Defaults to 'a'/'an'.

Comments and changes to this ticket

  • Yaroslav Markin

    Yaroslav Markin April 26th, 2009 @ 09:00 PM

    Could you please pastie a couple of examples — where do you use this in your code, does it really help a lot?

    Mixed feelings here, maybe some kind of I18n support required?

  • Troy

    Troy April 26th, 2009 @ 09:35 PM

    The case I've encountered is string-ifying a model instance as part of a phrase/sentence: http://pastie.org/458977

    It's more useful for displaying complete ideas -- step-by-step instructions, forms where model names aren't sufficient prompts (less savvy users), or when visitors search for lots of different words (search engine awareness).

    I agree about the I18n support concern.

  • Ryan Bigg

    Ryan Bigg April 26th, 2009 @ 11:38 PM

    This is too finnicky a change: http://en.wikipedia.org/wiki/A_a...

    How do you test for words with a silent H? You would have to compile a list of these words. I think you should implement it where you need it, perhaps make it a plugin.

    -1

  • Troy

    Troy April 27th, 2009 @ 12:43 AM

    IMO, you don't -- no test for sounds, just make clear what it does and doesn't do. It's a 95%+ solution, but failures are predictably obvious ("a herb") and deterministic. The 100% solution, if any, should be a plugin for the reasons you list.

  • Troy

    Troy April 27th, 2009 @ 06:01 AM

    Will attach another patch to support extensions for special cases (ie, herb), the same way that a few other inflection methods do.

  • Troy

    Troy February 22nd, 2010 @ 05:20 AM

    I haven't made time for it, so it doesn't make sense for anyone else to. Feel free to mark as invalid - I would but can't.

  • José Valim

    José Valim February 23rd, 2010 @ 09:14 PM

    • State changed from “new” to “invalid”

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

People watching this ticket

Attachments

Pages