0

At my website I have a button when pressed PHP script through ajax write session variable to change language and reload page. But when I enable caching every time is loading default language. When cache is disabled everything is OK.

How translations do big pages with caching?

0

If you have any kind of caching enabled on a site with Wordpress, IMHO, it's probably best to use cookies instead of session variables, because with caching enabled, the user's request for a page may not even hit the server at all — so the session var isn't even being read.

What I typically do is use cookies — both setting AND reading them on the front end via ajax. You could dynamically load the new language content that way.

––-––––-

Adding on to answer your second question. If you look at a plugin like WPML or something similar, they are actually creating duplicate content in many cases. So a site might be mydomain.com/en for English and mydomain.com/es for Spanish. Each endpoint is cached separately. Some cookies are probably set as well, but when you switch languages with WMPL, you are actually redirected to a different page, not the same page with different language content... if that makes sense?

| improve this answer | |
  • Thanks. Tomorrow i will try to change sessions to cookies and we will see..... – Sahasrar Apr 21 at 19:31
  • I dont know, in case of "mydomain.com/en" solution I dont understand if I have to duplicate whole website or just texts. Because I don't have too much free space to duplicate... It is some technique how to make those subfolders with language with texts change but website still same? – Sahasrar Apr 21 at 19:36
  • Yes, the WPML plugin basically makes a duplicate page for every one you create. When you create the page, it gives you the option of creating the duplicate in whatever languages you have configured. The images on the page can still be the same, but the text would be translated. It's a bit hard to explain, but I definitely recommend checking out WPML and experimenting with it to see how it works. It's much easier than building your own solution for translating Wordpress. – dkeeling Apr 22 at 20:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.