It look like the sfPropel::initialize isn't call at the right place.
When the user is loaded and the culture is set (sf_culture) the event
'user.change_culture' is called, however the
sfPropel::listenToChangeCultureEvent is not notified as it is not yet
registered.
More over, in the action if I do : $this->getUser()->setCulture($culture);
the sfPropel::listenToChangeCultureEvent is not notified. The
sfPropel::initialize is initialized when the view is rendered.
So with this issue the default language is used in Propel and not the
one defined by the user.
For now, I have overcome the bug by creating a filter.
class fixbugFilter extends sfFilter {
public function execute($filterChain) {
$context = $this->getContext();
$dispatcher = $context->getEventDispatcher();
$user = $context->getUser();
$request = $context->getRequest();
sfPropel::initialize($dispatcher);
$sf_culture = $request->getParameter('sf_culture');
if($sf_culture == null) {
$sf_culture = $user->getCulture();
}
if($sf_culture == null) {
$sf_culture = sfConfig::get('sf_default_culture');
}
if($request->getParameter('sf_culture') == null) {
$request->setParameter('sf_culture', $sf_culture);
}
$user->setCulture('-');
$user->setCulture($sf_culture);
$filterChain->execute();
}
}