I have a class called language.php in my environment which handles the language detection and includes the proper language file with all it’s variables.
When a template is not cached already, i cache it via APC and sent the cache entry to the visitor.
But now when i try to make my environment multilingual, and i change my languages from en-US to de-DE and then back to en-US i still get the cached de-DE template.
Are there any intelligent approaches to this problem that i can work with and elaborate?
EDIT:
My parsing/caching function: http://pastebin.com/PpHJ14Wv
I think that you should handle the template as 2 different templates (or as many languages that you are going to support). Instead of caching a template.html, for instance, you could cache a template-en.html and a template-de.html.
And use the url (example.com/en or example.com/de) or a $_SESSION[‘lang’] variable or something like that, in order to load the proper cached template.
EDIT
like so: