i recently start using CodeIgniter as PHP MVC FrameWork , before CodeIgniter, i was using my own small implementation of MVC Pattern , So , i was using language system build on constants like :
define( CONTACT_US , ' Contact Us ' ); and so … , but when i start using CodeIgniter , i see it use Language Class , so if we need to use a language in a view we need first to declare it like $lang['mainpage_contact'] = "Contact Us"; , when we need to pass it to view ,
$this->lang->load('mainpage' );
$date['contact'] = $this->lang->line('mainpage_contact');
and then pass it to view , in the first way , we can just define the constant and load the file , then use it directly in the view …
what is the best way ?
It’s always best to stick to the method your chosen framework uses. Then if you need help, or another programmer has to work on it, there’s no confusion. So I’d recommend going with the CodeIgniter way.
You also get the benefit of any future language features CI may add, and you can extend the Language class to add your own functionality. For instance you could use this Multi-Language Library to load the language depending upon your URI.