Experimental Project

This is a sandbox project, which contains experimental code for developer use only.

Taxonomy Pluralization for D6

When you use a vocabulary for content tagging, sometimes it can be easier and more secure to rely on your own pluralization instead of using the format_plural method.

For example in recipes, when you have white grapes, or a white grape. Or in packages, 1 box of crayons, or 4 boxes of crayons. Normally it would take some theme() or template magic, to get the output needed. But with this module it becomes a lot easier because you define the term 'box of crayons' and on the same screen you define the plural form of that term.

Usage

Install and enable module like always. Go to the /admin/content/taxonomy, and edit the vocabulary, check 'Pluralization' to enable it for that specific vocabulary, you can even check 'Pluralization required' to make sure that the plural is required.

This module does not alter any output on it's one, because it is hard to guess where you would like your pluralization to be based on ;) But i can give you a code example on how you could use it in code, based on a live example of an actual project i'm working on. It is a part of the above mentioned recipe CCK node. qty is received form a numerical field called quantity, but is rounded to one digit after the period because I might want to add some more magic (like transforming 1.5 in to 'one and a half' later on ;-)

if ($qty <= 1) {
                    $ingr = array('tid' => $tid,'name' => $variables['node']->taxonomy[$tid]->name);
                } else {
                    $ingr = array('tid' => $tid,'name' => $variables['node']->taxonomy[$tid]->plural);
                }

That's it.. if you have more then one, just print, echo or use $tax->plural, or else use $tax->name. The TID or VID of a term is not altered. The module hooks into schema, so you can use a normal taxonomy_get_term(). Not sure about views or other modules altering/generating output. Will have to look into that if support is needed :-)

Maintainers for Taxonomy Pluralization

  • ReneB - 1 commit
    last: 1 year ago, first: 1 year ago

Issues for Taxonomy Pluralization

To avoid duplicates, please search before submitting a new issue.
All issues
Bug reports
nobody click here