Reputation: 47
I have a controller that loads a language file, but that language file is only available for the function where i loaded the file. How can i make it available for all functions without being necessary to do $this->lang->load('main');
in all functions?
my controller:
class Main extends CI_Controller{
function _construct(){
parent::__construct();
//$this->lang->load('main'); //already tryed here doesn't load
}
function index(){
//$this->lang->load('main'); //if i do it here it's not available for the other functions
}
function homeL(){
}
function homeR(){
}
function messagesL(){
}
function messagesR(){
}
}
Upvotes: 0
Views: 167
Reputation: 151
The following solution works for me:
class Main extends CI_Controller{
function _construct(){
parent::__construct();
$this->lang->load('main','language');
}
Replace 'language' with the language you want to use. Without the second parameter CI uses the language specified in the config.php.
In the documentation you can find further information incl. the folder structure you have to use http://codeigniter.com/user_guide/libraries/language.html
Upvotes: 1
Reputation:
I think it's "hook case", so use hooks to pre-loading your lang file
Upvotes: 0