PHP simple translation approach - your opinion

Envolite

New Member
I am doing a PHP web site, without using any framework. I need that the site is available in several languages, and I was reading about it and it seems to be a little bit confusing. There are several solutions but all seem to depend on a specific framework.What you think of using a simple translation function like the one shown below?I mean, I would like to know what can be a disadvantage of using such code.Here it is (this is just a simple and incomplete sample):\[code\]class Translator{ private $translations; public function __construct(){ $this->translations = array( 'Inbox' => array( 'en' => 'Inbox', 'fr' => 'the french word for this' ), 'Messages' => array( 'en' => 'Messages', 'fr' => 'the french word for this' ) //And so on... ); } public function translate($word,$lang){ echo $this->translations[$word][$lang]; }}\[/code\]
 
Back
Top