As a non “en-us” locale user, this
item is very interesting for me and I’d like to contribute to it. Reviewing the current code of PluralizationService and related elements, I’d propose the following:
· Change the name from “PluralizationService” to “Inflector”, which is more commonly used for this service purpose in other technologies (Hibernate,
Raven...).
· Create a fallback system for the different implementations of Inflector instances, similar to the current fallback manager in System.Resources
· Use the Locator to solve all the registered Inflectors in InflectorFallbackManager, and if nothing is registered use the neutral
//The current pluralize service
publicclassNeutralInflector
: IInflector
{ }
//a new inflector,
publicclassSpanishInflector
: IInflector
{ }
publicclassInflectorFallbackManager
{
IInflector
GetInflector(CultureInfo
currentCulture);
}
Another
interesting thing will be to allow the user to register key value pairs of custom words, similar to the current ICustomPluralizationMapping, but as a public service, without the need to create a new Inflector. This new keys would be applied to whichever Inflector
was selected by the fallback manager. The next step could be adding a new mechanism in DbModelBuilder to indicate the culture for a specific item, overriding the current culture in the process of solving which Inflector to use.
Thanks
UnaiZorrilla