I’m proud to present the Portuguese Plural rules Plugin for Ruby on Rails (Version 1.0 beta)
This is a basic implementation of portuguese pluralization rules, more “convention over configuration” for all of you who want to use table names and models in portuguese. The plugin comes with documentation and test cases.
Copy the plugin to your project/vendor/plugin/ directory and just create your tables and models as normal.
You can also test if a word gets correctly pluralized by:
1) running “ruby script/console”
2) write “palavra”.pluralize
3) or “palavra”.singularize
1) Add rules and examples for the following:
-if word ends in “s” and has one silable, trade “s” with “es”
2) Improve list of irregular words for the following rule:
-if word ends in “ão”, there are three ways of plural: ãos, ães, ões
These rules depend on the number of syllables, so that might help a bit, but I’m no expert in Regex.
3) Add cases of uncountable words to the list
4) Fix other unknown bugs.
5) Improve test cases
I haven’t setup SVN yet so the only way to download (for now) is by download from here.
Enjoy and don’t forget to send me some feedback.