Welcome Guest, Not a member yet? Register   Sign In
Loading Languages File directly to Array
#1

[eluser]shaffick[/eluser]
Hey guys,

I have a question regarding loading languages, and maybe I'm missing something here, not sure.

Currently, from the documentation, I noticed the following
Code:
$data['title'] = "My Real Title";
$data['heading'] = "My Real Heading";
        
$this->load->view('blogview', $data);

and we also have this to get a particular error message: $this->lang->line('language_key');

I tend to separate my language specific items for separate sections in separate files (and I have a lot of placeholders). My question is...I want to load my language filelines directly into the $data array...does CI offer this already or do I have to make a helper for myself.

Pretty much something like this:
Code:
// it loads all the lines from somefile.php into the data array
// ready to be passed to the 'view' file.
$data = $this->lang->load('somefile');  

$this->load->view('blogview', $data);

Please let me know if the above does not make sense. I can make a little helper to facilitate this...but I just wanna do it the CI way and was wondering if CI already offers such a functionality somewhere.

cheers,
Shaffick
#2

[eluser]xwero[/eluser]
i've written an extension for the language class : MY_Language (the SqlLang section) which does what you require. You don't have to use all the method that i added, the methods select and get together with the variable $_get will be enough if you want to add the lines manually. If you have a prefix or postfix you use to identify from which file the lines are you could add the like method.
Code:
$data = $this->lang->select('line1','line2')->get(); // gets line1 and line2
$data = $this->lang->like('line')->get(); // gets all lines prefixed by line




Theme © iAndrew 2016 - Forum software by © MyBB