Hi everyone,
I am working currently on a new Website with frames, the layout is done and everything works perfect.
I plan to offer my visitors to select which language they want to use, for now I have english and german, of course. I keep the translations in 2 files, like lang.eng.php and lang.deu.php, inside I have the data like :
// german text in lang.deu.php
$msg_welcome = 'Willkommen auf meiner Homepage';
// english text in lang.eng.php
$msg_welcome = 'Welcome to my Homepage';
This is how I include the files :
function language_file(){
global $language;
if (!is_file("/path/to/my/server/lang/lang.$language.php")) {
return "/path/to/my/server/lang/lang.deu.php";
}
return "/path/to/my/server/lang/lang.$language.php";
}
And each page in my frameset loads the language file with :
require ("/path/to/my/server/includes/config.inc.php");
include(language_file());
Okay... so far, this works, I have three pages in my frameset, a page for the menu with the links, a page for displaying the main content, and a page for a banner on top with some text.
Each page has it's content, of course, and general things like Headers or Definitions, example ... to "say hello", i do ...
echo $msg_welcome;
... and of course it echos the text in the language of the included language file.
So if I access index.php?language=eng, it loads my Website with english text, no problem.
But if I click on a link so that it loads that page in the main content frame, it appears in german again with is the default language file - it seems to have 'forgotten' about the variable already set.
I am aware that my global variable would only be available for the funtion itself. So I checked Google and several Forums for an idea how to solve this problem, I heard of Superglobals already.
Is there a workaround for this, that does not need passing the $language value with link1.php?language=eng, for example or to have to create a session and register the variable language ?
If anyone has an idea, I would be all thankful. Thank you for reading my post already, if I have forgotten important informations here, please let me know.