4

Closed

UpForGrabs: Turn pluralization & singularization into a pluggable service

description

This would allow anyone to implement non-English version of the service and configure it using a resolver.
Closed Mar 1, 2013 at 8:33 PM by RoMiller
Murat verified this.

comments

UnaiZorrilla wrote Dec 12, 2012 at 10:26 AM

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
public class NeutralInflector : IInflector { }



//a new inflector, 

public class SpanishInflector : IInflector { }



public class InflectorFallbackManager 

{

    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.

UnaiZorrilla

ajcvickers wrote Jan 7, 2013 at 9:41 PM

Fixed by Unai. The approach is basically what was discussed in the design meeting:
  • PluralizationService becomes IPluralizationService and is made public
  • The IPluralizationService to use is resolved globally using IDbDependencyResolver (No automatic selection based on locales.)

RoMiller wrote Mar 1, 2013 at 8:29 PM

Moving from Future into EF6 because this was contributed for the EF6 release.