Development

#3261 (sfPropel & i18n - r8206)

You must first sign up to be able to contribute.

Ticket #3261 (closed defect: fixed)

Opened 8 months ago

Last modified 8 months ago

sfPropel & i18n - r8206

Reported by: rande Assigned to: fabien
Priority: minor Milestone: 1.1.0 beta3
Component: other Version: 1.1.0 DEV
Keywords: Cc:
Qualification: Unreviewed

Description

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();
	}
	
}

Change History

04/02/08 13:39:26 changed by fabien

  • milestone set to 1.1.0.

04/04/08 18:16:31 changed by fabien

  • status changed from new to closed.
  • resolution set to fixed.

(In [8296]) fixed sfI18n and Propel (closes #3261 - it took me 6 hours to fix it)

04/04/08 18:16:42 changed by fabien

  • milestone changed from 1.1.0 to 1.1.0 beta3.