Another Solution Try:--
Create Abstract class
interface Language
{
public function getPageTitle();
public function getHeaderTitle();
public function getSiteName();
public function getSlogan();
public function getHeading();
public function getMenuLogin();
public function getMenuSignup();
public function getMenuFindRide();
public function getMenuAddRide();
public function getMenuLogout();
}
Though the interface is small, implementing it may produce a big file, though it would arguably be clearer than the array style:
class English implements Language
{
public function getHeaderTitle()
{
return 'My website header title';
}
public function getHeading()
{
return 'Heading';
}
// etc...
}
Alternative:--
Alternatively, you could combine these styles and have a singleton Language with getter methods accessing that array, i.e.:
class Language
{
private $languageArray;
private $userLanguage;
public function __construct($language)
{
$this->userLanguage = $language;
$this->languageArray = self::userLanguage();
}
private static function userLanguage()
{
$file = '/path/to/language/config/' . $this->userLanguage . '.ini';
if(!file_exists($file))
{
//Handle Error
}
return parse_ini_file($file);
}
public function getPageTitle()
{
return $this->languageArray['PAGE_TITLE'];
}
public function getHeaderTitle()
{
return $this->languageArray['HEADER_TITLE'];
}
//etc...
}
Which will provide the benefits of both. Personally though, unless you're planning on adding more languages in the very near future, I believe solution #2 would suit you best.