Jump to content

Recommended Posts

Posted

The guest user language will be provided by default. You can change it.
If you want to control it via get parameter you need to hook in ProcessLogin::execute();
Pick up the language ID from the url get parameter and set the user language in a hookBefore.

  • Like 1
  • 5 weeks later...
Posted

Hey @kixe Thanks for your answer. However, I couldn’t hook in correctly. I tried every hook from "ProcessLogin". The most suitable seemed "buildLoginForm" or "renderLoginForm", because I want the form itself to be translated. None of my hooking attempts seemed to be executed. This is from my init.php:

$wire->addHookBefore('ProcessLogin::buildLoginForm()', function($event) {
	wire('log')->save('langlog', 'language should be: '.wire('input')->lang);
	if (wire('input')->lang == 'fr') {
		wire('languages')->setLanguage(7085);
	}
});

I cannot explain why there is no log entry after visiting mysite.com/processwire/?forgot=1&lang=fr

Posted
2 hours ago, gerritvanaaken said:

This is from my init.php:

Does it all also not work when executed in the ready.php?

Posted

Here is my final init.php code for bilingual password forgot.

if (wire('session')->language) {
	wire('languages')->setLanguage(wire('session')->language);
}

$wire->addHookBefore('ProcessLogin::execute', function($event) {
	if (wire('input')->lang == 'fr') {
		wire('languages')->setLanguage(7085);
		wire('session')->language = 7085
	}
});

 

  • Like 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...