By tomas.teicher on
H
what is the best way to execute some PHP commands when user swicth website to another language?
D7 have some hooks concerning language but there is no hook for switching the language.
I can change language switcher links in that way that I add some URL parameter to them. Then I can test in hook_init() whether some language switcher link was clicked.
Is there any simplier solution?
Comments
You can always store the
You can always store the current language in a $_SESSION variable, and if you load the page and the language is different from the previous one, execute your code.
Contact me to contract me for D7 -> D10/11 migrations.
I think you can use the
You can use the variable $language, for example:
The language information for each user is already stored here, so might as well make use of it. More info here.
thanks for the tips
thanks for the tips
I will test language change using session (using global $language)
thanks
Tomas