Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

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

#2566

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'.

Reported by Troy · April 26th, 2009 @ 08:51 PM

State: invalid
Milestone: 2.x
Assigned to: nobody
Importance: none

Activity

  1. Yaroslav Markin
    Yaroslav Markin

    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?

    April 26th, 2009 @ 09:00 PM

  2. Troy
    Troy

    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.

    April 26th, 2009 @ 09:35 PM

  3. Ryan Bigg
    Ryan Bigg

    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

    April 26th, 2009 @ 11:38 PM

  4. Troy
    Troy

    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.

    April 27th, 2009 @ 12:43 AM

  5. Troy
    Troy

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

    April 27th, 2009 @ 06:01 AM

  6. Troy
    Troy

    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.

    February 22nd, 2010 @ 05:20 AM

  7. José Valim
    José Valim
    • State changed from new to invalid

    February 23rd, 2010 @ 09:14 PM