Welcome Guest, Not a member yet? Register   Sign In
Improved Inflector singular() and plural() functions
#1

[eluser]milkboy[/eluser]
Hi all,

I made a port of the CakePHP Inflector class, as the CI helper is a bit limited. Contains only two files MY_inflector_helper.php and a inflector.php config file containing the rules (so it is easy to extend and all the rules only get loaded if needed)

I do not have a lot experience posting stuff, so any feedback welcome.

PS: Am I correct in thinking there is no problem with copyright here, as I clearly stated what the base of my code is and acknowledged copyright. If I have broken any rules or done anything I shouldn't have, please let me know.
#2

[eluser]Tominator[/eluser]
Why is this one better then CI's? (Why should I use it?)

Tom.
#3

[eluser]milkboy[/eluser]
The CI helper just checks a few of the most common rules. This one checks many more. Additionally as all the rules are included in a config file, they can easily be extended. If you notice a word is not being processed correctly, just add it to the config file. If anybody can't figure out how to implement or amend this script, just let me know (but should be logical with very basic CI knowledge).

As a final point, as the rules are in a config file, this could be used as a starting point to create rules to work with other languages.

Here are some words (singular form|plural form), CI does not process correctly:

quiz|quizzes
ox|oxen
mouse|mice
matrix|matrices
index|indices
person|people
man|men
child|children
tomato|tomatoes
alias|aliases
crisis|crises
tax|taxes
analysis|analyses
atlas|atlases
loaf|loaves
octopus|octopuses
equipment|equipment
information|information
media|media
Portuguese|Portuguese
rice|rice
tuna|tuna
#4

[eluser]Nicolas Connault[/eluser]
Actually if you are going to use the proper plural for Latin words like index, you should also use the proper plural for Greek words like octopus: octopodes Smile
#5

[eluser]murphy2006[/eluser]
Where can I find this download?
#6

[eluser]jmadsen[/eluser]
Very nice! I'm a big fan of people porting/sharing libraries from other frameworks & apps, and yours seems well thought out
#7

[eluser]Unknown[/eluser]
Seems like the file is not available for download anymore?




Theme © iAndrew 2016 - Forum software by © MyBB