Open atrimech opened 9 years ago
My guess is you'll need to play with EventListeners and Dependency Injection. I'm not exactly an expert in those matters, but I'll try to help anyway.
Taking a quick look at JMSI18nRoutingBundle code, you can find this: https://github.com/schmittjoh/JMSI18nRoutingBundle/blob/master/EventListener/LocaleChoosingListener.php and specially https://github.com/schmittjoh/JMSI18nRoutingBundle/blob/master/Router/DefaultLocaleResolver.php
You should be able to make your own LocaleResolver (a class that implements LocaleResolverInterface) and inject the entity manager (@doctrine.entity_manager) into it. Then you can inject your LocaleResolver to an onRequest event or something similar to the above-mentioned LocaleChoosingListener. So on each request, you have your LocaleResolver (that relies on entity manager) to look into the database for the default locale
As per the bundle itself, I think what you want to do could be added as a feature. I mean, adding a config option in JMSI18nRoutingBundle, maybe something called jms_i18n_routing.locale_resolver, which gave us the oportunity to choose our own LocaleResolver class or service to be injected in the JMSI18nRoutingBundle/EventListener/LocaleChossingListener.php
This is actually a duplicated of https://github.com/schmittjoh/JMSI18nRoutingBundle/issues/150
Hi all,
I have add a new configuration in my backend web site, that i can change the language of all website, so, it's work perfectly, but what i want to do now, is the web site open with the language set on database, but i'm already using JMSi18nRoutingBundle, where my default locale is set fr for exemple, how can i tell to JMSi18nRoutingBundle config to change the default locale from database.
Is that possible ?