ISSUE 599 Contribution

Topics: EF Runtime
Dec 12, 2012 at 1:52 PM
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.
 
 
Thanks
 
UnaiZorrilla
Developer
Dec 14, 2012 at 11:07 PM

Hi Unai,

We discussed this in yesterday's design meeting. We are definitely interested in contributions in this area. The team had quite a few ideas here which are recorded in the design meeting notes. Please consider this an ongoing discussion; that is, if you believe that the ideas in the notes can be improved upon we're certainly interested in hearing about it.

Thanks,
Arthur

Dec 15, 2012 at 10:17 PM

Hi Arthur,

I will be happy to help in any way, however, after reading the notes I will be discussing the following items:

 
Which is the mechanism with this approach for override some words-terms in the existing pluralization service or in a new implementation? This is a interesting feature for override some elements like OrderCustomer (OrderCustomers or OrdersCustomers..) IMHO
 
If you use pluralization in many other services/conventions the user need re-register all services/conventions to change the pluralization? Why no set this element as a service in locator, it is a perfect candidate IMHO?????
 
 
Unai Zorrilla
Developer
Dec 17, 2012 at 5:18 PM

Hi Unai,

We're not totally against making it available from the Service Locator. But keep in mind that:

  • Current behavior cannot change regardless of any locale read from the machine. In other words, if we currently do English pluralization, then we must continue to do so even when running on non-"en-us" machines.
  • It could be either a transitive or global service, but in either case there would need to be reasonable answers for:
    • The key (if any) used to lookup the service
    • Whether or not the service is mutable

The mutability of the service is especially relevant with regard to adding words. It seemed to us that it only makes sense to add words when the language is known and hence the addition of words should be coupled to the pluralization service in use. We think it's probably best to only allow addition of words before the service is registered such that it becomes immutable afterwards. What this means is that the addition of words is probably just part of the implementation of the pluralization service and can be handled appropriately and differently by different implementations as necessary, or not included at all for implementations that use different approaches where word addition is not appropriate.

It wasn't clear to us that all this work was really necessary or would really be used if it was done, but we're not against it if it seems like the end result adds value.

Thanks,
Arthur

Dec 17, 2012 at 8:22 PM

 

Hi Arthur,

what do you you think about the following ?

- Preserve the current PluralizingService implementation ( to provide compatibility )
- Who would use this service will resolve it using the Locator in any culture
- We would allow the user to replace the service ìmplementation registering a new instance in Locator (no fallback process).
- We could add the possibility to include Custom Words in PluralizingService,  but only  before registering it in the locator

Best regards,

Unai

  

Developer
Dec 17, 2012 at 8:54 PM

Hi Unai,

Yes, I think that sounds okay. It's basically where we got to in the design meeting if it were going to be done using the Service Locator.

Thanks,
Arthur

Dec 17, 2012 at 9:01 PM

Arthur

 working..