I'm building a simple multi-languages system. I've created a class called Language that is loaded by my controller, the class is very simple:
class Language
{
private $_langPath = null;
function __construct()
{
$this->_langPath = 'languages/' . LANGUAGES . '/trans_mig.php';
if(!file_exists($this->_langPath))
{
throw new exception("File not found: " . LANG);
}
else
{
include $this->_langPath;
}
}
public function line($key)
{
return $lang[$key];
}
}
inside the trans_mig.php
I've the following:
$lang['home'] = 'Home';
$lang['user'] = 'User';
but when I do for example this:
$this->lang->line('user');
I get the following error:
Notice: Undefined variable: lang
in the file that I've included the trans_mig.php
, what am I doing wrong?