I downloaded the Graphene theme and made tests with it. Browsed my test site, made search… in default and non default language. Sorry, but I did not reproduce any undesired language switch.
However I detected a big incompatibility between Polylang and Graphene when requesting a non existing page. The redirection setup on Error 404 by the Graphene theme either loops or breaks the language detection…
Hm… I still have the problem though…
Anyway, thanks for the help.
Are there any code parts where polylang automatically changes the language of a page (Or is the page language set dynamically anyway?)? If this can be easily listed it would be nice if you could point out the code parts – if it takes too much time then don’t; eventually I will find the problem – I hope 😉
If I know in which cases automatic language changes are done I could maybe find a way to reproduce the problem better…
In any case I will test more and report back.
The problem is definitely connected to the problem of requesting non-existing pages. If I do that it will always happen.
Can you maybe describe what you mean by “breaks the language detection”?
I still don’t really understand how it can happen that the language of the page is just changed. I mean there must be some table somewhere that states clearly which page id has which language (Or each page remembers it…). It should not be possible to just change that automatically (That’s my feeling, I don’t really know how the plugin is implemented…).
This might also be interesting: Once the language of the page was changed the translation of the page points to itself.
EN page id = 2, DE page id = 14
OK:
DE(id = 14) -> EN id = 2, EN(id = 2) -> DE id = 14
After automatic change:
DE set to EN(id = 14) -> DE id = 14, EN(id = 2) -> DE id = 14
So the German page changes its language to English and points back to itself for the German translation while the English page did not change (it still points correctly to 14, the problem is just that the language of 14 was changed to English…).
The way the language detection works much depends on the page requested.
For posts, pages, categories and post tags, Polylang just stores the language in the database.
For archives, the language is added to the URL (Polylang modifies all links to archives to add the language code in the link).
For the home page and 404, the language is either set by a cookie or the browser preference or the default langage.
For the search result, the language is added to the URL. Polylang does modifies the search form. But it does not modify the direct request done in 404.php by the Graphene theme. So it does not know which language to load.
I did not make deep tests but the following modifications may help.
Edit graphene/theme.php and replace the line 13
$redirect_location = get_home_url().'?s='.$search_term_q.'&search_404=1';
by
$lang = reset(explode('_', get_locale()));
$redirect_location = get_home_url().'?lang='.$lang.'&s='.$search_term_q.'&search_404=1';
Thanks a lot! That seems to be working.
If the problems appears again I will try to report the steps how to reproduce it clearly 🙂
i am using qtranslate plugin. have 2 language. default language is ka_ge, but at first run of start page, it changes automatically ?lang=en. if i put again my site homepage url it opens correctly. what’s wrong?
@machwi You wrote you are using qTranslate but here the topic is tagged as Polylang (not qtranslate) so you won’t find qTranslate users reading this. It would be better to post on the qTranslate Forum.