I presume each translation file is of the form
varname = value
varname2 = value2
So for example if the desired language is set as a GET parameter, you could just have an array variable in the class:
class MyClass
{
var $trans = array();
function myClass()
{
if(file_exists($_SERVER['DOCUMENT_ROOT'] ."/". $_GET['lang'] .".txt"))
{
$file = file($_SERVER['DOCUMENT_ROOT'] ."/". $_GET['lang'] .".txt");
}
else
{
$file = file($_SERVER['DOCUMENT_ROOT'] ."/en.txt");
}
foreach($file as $value)
{
$value = explode(" = ", $value);
$this->trans[$value[0]] = $value[1];
}
}
function getTranslation($key)
{
if(isset($this->trans[$key]))
{
return $this->trans[$key];
}
}
}